--- a/candolint/models.py Wed Jul 06 21:21:47 2016 +0800
+++ b/candolint/models.py Thu Jul 07 13:31:08 2016 +0800
- def create_or_get(cls, **kwargs):
+ def manual_upsert(cls, **kwargs):
with cls._meta.database.atomic():
return cls.create(**kwargs), True
field = getattr(cls, field_name)
if field.unique or field.primary_key or field_name in compound_unique:
query.append(field == value)
- return cls.get(*query), False
+ instance = cls.get(*query)
+ for field_name, value in kwargs.items():
+ setattr(instance, field_name, value)
class Project(BaseModel):
--- a/incoming.py Wed Jul 06 21:21:47 2016 +0800
+++ b/incoming.py Thu Jul 07 13:31:08 2016 +0800
domain, user, name = parse_project_url(url)
with database.transaction():
- project, created = Project.create_or_get(
+ project, created = Project.manual_upsert(
- change, created = Change.create_or_get(
+ change, created = Change.manual_upsert(