-
Notifications
You must be signed in to change notification settings - Fork 7
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
Incorrect input field specification for POST methods #26
Comments
cc @NinadBhat basically we should consider either having separate models for getting/creating, or encoding additional information on each |
and yeh this is why I have currently kept https://github.com/aiidateam/aiida-restapi/blob/master/aiida_restapi/aiida_db_mappings.py separate from |
in production code, it seems that people do indeed define separate models for
In our case, for most entities (except |
yeh indeed we should definitely at least split those two up. In terms of e.g. TBH its made it a bit "confusing", that you have the AiiDA ORM classes, which are not technically the same as the backend sqlalchemy/django ORM classes, but that with the (this also relates to #1, i.e. where can you get what the "source of truth" is for the ORM fields 🤷) |
Basically the fields you can return from an ORM entity (via
QueryBuilder
) are not the same as the fields available to create an ORM entity, e.g. here it suggests you can specify theid
anduser_id
, which is not true:equally the way the pydantic models are set up in
models.py
, IMO, feel a bit "off":Here, everything except for
label
is set asOptional
, since this is the only required field to create a group. But this does not accurately describe what is stored in the database, and thus what you would return from a GET method, where things likeid
are not optional (i.e. it should never beNone
).Finally, fields like
user_id
will be returned from e.g.QueryBuilder().append(Group, project=["**"])
, because they are a field on the database table, but they will always beNone
when usingfrom_orm
, because they are not exposed as an attribute of the AiiDA ORM class.FYI this is what I was talking about in #17 (comment) @ltalirz
Also note the
/groups
POST method is currently calledcreate_user
😜The text was updated successfully, but these errors were encountered: