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

Custom ID support (string, UUID, etc) and misc bug fixes #81

Merged
merged 10 commits into from
Dec 31, 2024

Conversation

lrstanley
Copy link
Owner

@lrstanley lrstanley commented Dec 31, 2024

🚀 Changes proposed by this PR

  • BREAKING: renamed Config.AllowClientUUIDs to Config.AllowClientIDs to indicate that it's not specific to UUIDs, but rather any scenario where you want to allow the client to provide their own ID for the CREATE request.
    • Ensure Config.AllowClientIDs actually has an impact. Previously, it only added it to the spec, but didn't add it to the server request handling logic. It's now correctly added to the spec, and the server knows how to handle when a custom ID is provided.
    • WithAllowClientIDs can now be used to toggle this feature on/off on a per-schema basis.
  • Added support for ID fields with the underlying types of: string, int, and any other custom type that implements the following interfaces: encoding.TextUnmarshaler, json.Unmarshaler, and encoding.BinaryUnmarshaler (in that order of priority).
    • Switched some tests to include string and UUID-based ID fields.
  • Fixed an issue where if an ID field had a custom package type, it may not import the correct package (e.g. uuid.UUID{} could import Google's library, or some other random one that you happen to have locally).
  • Improved wording of the id field in the spec, when IDs can be generated on behalf of the CREATE request, when using AllowClientIDs.
  • Filter fields in the spec now inherit the format field. For example, id.in on /users now is an array of uuid format type.
  • Removed performance suggestion wording from the spec for ?pretty=true.

🔗 Related bug reports/feature requests

🧰 Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that causes existing functionality to not work as expected).

fix: ensure that AllowClientIDs actually has an impact on CREATE input parameters
Signed-off-by: Liam Stanley <liam@liam.sh>
ensures that when using UUID packages (for example), the wrong one isn't imported

Signed-off-by: Liam Stanley <liam@liam.sh>
… & AllowClientIDs

Signed-off-by: Liam Stanley <liam@liam.sh>
Signed-off-by: Liam Stanley <liam@liam.sh>
- also includes a few fixes where it was using the wrong ent graph field for determining the ID field type.
- switched some schemas in kitchensink, and testdata to use uuid and string-based ID fields.
- supports almost every potential ID usecase that Ent supports (effectively anything that supports string, int, texts unmarshaller, json unmarshaller, or binary unmarshaller).

Signed-off-by: Liam Stanley <liam@liam.sh>
Signed-off-by: Liam Stanley <liam@liam.sh>
@lrstanley lrstanley marked this pull request as draft December 31, 2024 04:05
Signed-off-by: Liam Stanley <liam@liam.sh>
Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.85%. Comparing base (c0a64c6) to head (1173a13).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
+ Coverage   68.38%   68.85%   +0.46%     
==========================================
  Files          10       10              
  Lines        2442     2456      +14     
==========================================
+ Hits         1670     1691      +21     
+ Misses        657      651       -6     
+ Partials      115      114       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Liam Stanley <liam@liam.sh>
Signed-off-by: Liam Stanley <liam@liam.sh>
Signed-off-by: Liam Stanley <liam@liam.sh>
@lrstanley lrstanley marked this pull request as ready for review December 31, 2024 05:26
@lrstanley lrstanley merged commit c14c041 into master Dec 31, 2024
29 of 32 checks passed
@lrstanley lrstanley deleted the feeature/custom-id-types branch December 31, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant