-
Notifications
You must be signed in to change notification settings - Fork 34
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
Cayenne entity ID part represented by a DB column to be prefixed with "db:" #521
Milestone
Comments
andrus
added a commit
that referenced
this issue
Jan 7, 2022
…h "db:" #521 .. unifying update and select queries
andrus
added a commit
that referenced
this issue
Jan 7, 2022
…h "db:" #521 .. using ID reader to fill AgObjectId
andrus
added a commit
that referenced
this issue
Jan 7, 2022
… "db:" #521 .. parent ID handling .. more id cases
andrus
added a commit
that referenced
this issue
Jan 7, 2022
… "db:" #521 .. deprecating AgObjectId.get()
andrus
added a commit
that referenced
this issue
Jan 7, 2022
… "db:" #521 .. handling parent in updates
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Background - ID representation in Agrest
Entities can have single-value and multi-value IDs. Single-value id is represented in JSON as
"id":val
. Multi-value - as"id":{"p1":v1, "p2":v2}
. This representation is used for both request bodies (POST, PUT), and responses (GET, POST, PUT).Problem
This task is concerned with a specific case - multi-value ID representation with Cayenne backend, when one or more values in the ID map are not present as object properties. In this case Cayenne uses names of DB columns as keys in the ID map:
"id":{"col1":v1, "col2":v2}
.This is both confusing, and can potentially (though unlikely) cause naming conflicts between Java properties and DB column names in the same id map. Additionally, since 5.0 (per #520) attributes and "id part" attributes no longer maintain "path expression" property separate from the attribute/id part name. So the name itself should contain sufficient information for the backend to make sense of it.
Solution
While we can keep building workarounds in the Cayenne backend, I think we should change the encoding of the column-based id parts to be in a form of Cayenne DB expression, i.e. prefixed with "db:" -
"id":{"db:col1":v1, "db:col2":v2}
. This will add both visual clarity and disambiguate the ID structure for the framework.Upgrade Notes
This change only affects Cayenne entities that have a multi-column ID, and only a subset of id properties that are not mapped as object properties. Property names that are column names will now be prefixed with "db:". E.g.:
"id":{"db:col1":v1, "db:col2":v2, "prop":v3}
.On the client this affects the following requests:
On the server this affects the following user-facing APIs:
SelectBuilder.byId(Map)
SelectBuilder.parent(Class,Map,String)
UpdateBuilder.parent(Class,Map,String)
DeleteBuilder.parent(Class,Map,String)
The text was updated successfully, but these errors were encountered: