-
Notifications
You must be signed in to change notification settings - Fork 192
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
Allow usage of pk
in QueryBuilder
project and filter statements
#2577
Comments
@CasperWA I remember you mentioning this at some point: |
Aw. Is this due to the fact that |
Yes, this is why django uses PK. |
And also why we do not want too? (@sphuber, @giovannipizzi) |
Exactly. My opinion is that since |
I also vote for consistency and for pk over id since we are using it a lot already. |
Yes, you are correct. The |
This is now implemented by #5088 |
The database models use
id
as the column name for the primary key, but unfortunately,id
is a reserved keyword in python. This is also the reason that Django usespk
to refer to the primary key column. In AiiDA we are using a mixture. Some of the ORM classes define both theid
and thepk
property, where thepk
property just proxies through to theid
one.Ideally we would change the database models to use only
pk
and then we would only usepk
throughout the code. Even just restricting the usage ofid
to the database models and usingpk
exclusively everywhere else would already be an improvement.But the worst is that currently sometimes a user can use either name, but sometimes one has to use
id
. For example, attempting to filter onpk
in theQueryBuilder
yields the cryptic message:The same goes for when projection e.g.
project=['pk']
.We should in increasing importance:
pk
pk
id
inQueryBuilder
id
anywhere in the codeThe text was updated successfully, but these errors were encountered: