Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For
kafka_skip
to work properly, We need to treat the following cases differently:When we create Model instances directly, either with or without PK specified. e.g.
User.objects.create(id=1, kafka_skip=True
orUser.objects.create(kafka_skip=True)
.In this scenario we never need to set the
kafka_skip
value since thekafka_skip
value was either set directly or it will default toFalse
since the model field hasdefault=False
.When we retrieve an instance from DB, and save it again. E.g:
In this scenario, the DB loaded value (
retrieved
) haskafka_skip=True
. Upon saving we want to resetkafka_skip
toFalse
only ifkafka_skip
was not set directly betweenget()
andsave()
.Both scenarios are covered by adding a
reset_kafka_skip
variable and setting it correctly in_setattr_
,__init__
, andfrom_db
.Advantages:
QuerySet.create
,QuerySet.get_or_create
,QuerySet.update_or_create
.update_fields
is not specified. Which is ideal as an open source package, since not everyone utilisesupdate_fields
.