Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let IntegerVersionField starts with '1' #150

Open
shintophilip opened this issue Mar 1, 2019 · 4 comments
Open

Let IntegerVersionField starts with '1' #150

shintophilip opened this issue Mar 1, 2019 · 4 comments

Comments

@shintophilip
Copy link

shintophilip commented Mar 1, 2019

Suppose we have a model,

class User(models.Model):
    version = AutoIncVersionField()

    id = models.UUIDField(primary_key=True, default=uuid.uuid4)
    name = models.CharField(max_length=255)

If we create the object using create, we are getting the expected version value(which is 1).

User.objects.create(name='name')

But instead of that if we create the model using the initializer and create it using the save() method. The version is 2.

user = User(name='name')
user.save()
@saxix
Copy link
Owner

saxix commented Mar 1, 2019

IntegerVersionField is not what you are looking for. Check AutoIncVersionField. Please consider that you should not add semantic to those values and ignore them, because concurrency is a low level system that should not be exposed to the business logic.

@shintophilip
Copy link
Author

shintophilip commented Mar 3, 2019

Yes. It was a mistake while copying the code. It is AutoIncVersionField.

Agreeing to your point that - concurrency is a low level system that should not be exposed to the business logic. There is no harm in version getting initialized with 2 while creating a model with version with value 2. Thought the expected behavior of AutoIncVersionField is always to increment by 1.

@saxix
Copy link
Owner

saxix commented Mar 28, 2019

yep, probably is true and I keep this issue opened as enhancement

@saxix saxix changed the title Records are created with version 2 instead of 1 when we use save() method. Let IntegerVersionField start with '1' Mar 28, 2019
@saxix saxix changed the title Let IntegerVersionField start with '1' Let IntegerVersionField starts with '1' Mar 28, 2019
Copy link

github-actions bot commented Apr 4, 2025

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants