-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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
Fixed #27452 -- Added SerialField and BigSerialField to contrib.postgres. #7525
Conversation
76a6a50
to
1e0986c
Compare
I hate to throw a spanner in the works, but this would be a lot simple if/when this is merged: #7515 Something along the lines of
|
@wengole yes, that would be cool, but whoever comes last hast to refactor ;) It is really only a couple of lines in both cases. |
f55aa79
to
7104fa1
Compare
I changed a couple of things, I don't know tho, if this field is ready year. Currently every insert would result in an extra query, where the field should use |
edd4851
to
5d1af7a
Compare
Well, I'm currently writing a DEP targetting precisely this problem. Serial is just a part of a more generic problem we need solved once and for all. Do you want to participate on the DEP ? |
(For the record : #7515 (comment) ) |
Hey guys, Thanks, |
We are waiting for this PR to be merged. Very useful |
@syurchenko I will resume my work on this once #6385 is merged. |
@codingjoe #6385 is merged. Can I give you a bump to resume work on this? I know I'd like to see this feature land! We use uuid's but need serial int ids for other uses, so this would be a great addition to the postgres contrib. Thanks. |
@codingjoe I ended up going off of what you had done in order to build a custom I did add the below method, or else it wasn't creating the field in the database. But other than that, I pretty much went off of what you had: class SerialField(Field):
# ...
def db_type(self, connection):
return 'serial' |
@aronysidoro yes sure, be my guest to try. I do have more time now, since my other big PR is merged, but I have another one too. |
@codingjoe ok, I am going to try. So, it sounds like the big problem would be when using the |
@codingjoe I have looked into this several times. I just want to follow up. So far, I haven't seen where a single One place I looked at in particular was https://github.com/django/django/blob/master/django/db/models/query.py#L458 It looks like the code is looking for objects without a It seems like the code would need to use the Any thoughts? |
Hi @aaronlelevier I know there isn't a simple way to inject this. django/django/db/backends/postgresql/operations.py Lines 225 to 226 in d2afa5e
django/django/db/backends/postgresql/operations.py Lines 64 to 70 in d2afa5e
and this one: django/django/db/backends/base/operations.py Lines 173 to 179 in d2afa5e
They all need to be able to not only unpack a single but all values for the fields that are specified within your method. btw, that method should return the fields in a deterministic order. Does that help you? |
@codingjoe thank you for your reply. I am going to look into your recommendations above. Yes, it definitely helps. I was looking at Django 1.11, but I see the PR that you linked above is from Nov 29th, so there's new code then for some of the logic that SerialField could use that I hadn't seen. Great, thank you. |
e2d5504
to
846c6e2
Compare
8708d4b
to
487285c
Compare
487285c
to
ddedea4
Compare
Thanks for the review @charettes, but this will have to wait until after #9983 anyways. I will close the PR for now and open it, once #9983 is merged. |
@codingjoe I notice the PR you mentioned has been merged, should this be reopened? |
https://code.djangoproject.com/ticket/27452