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

[4.x] Improve id generators #1300

Merged
merged 4 commits into from
Jan 21, 2025
Merged

[4.x] Improve id generators #1300

merged 4 commits into from
Jan 21, 2025

Conversation

stancl
Copy link
Member

@stancl stancl commented Jan 17, 2025

  • Add bigint generator
  • Add an option to store hex bytes as raw bytes? Figure out how casts and queries would work here. UUIDs have a uuid() string type (in migration syntax) but are used as strings, I'm not sure if we could do the same with an arbitrary binary column
  • Consider a snowflake generator

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.67%. Comparing base (8b131ed) to head (760db83).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1300   +/-   ##
=========================================
  Coverage     84.66%   84.67%           
- Complexity     1053     1054    +1     
=========================================
  Files           176      177    +1     
  Lines          3084     3086    +2     
=========================================
+ Hits           2611     2613    +2     
  Misses          473      473           

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

@stancl
Copy link
Member Author

stancl commented Jan 21, 2025

Looks like storing random raw bytes would be inconvenient because even if we add some Eloquent accessors and setters, where() clauses still need to be able to format the data and there are many cases where Eloquent may be bypassed. UUIDs seem unique in that DB engines can transparently convert between the string representation and the byte storage. So we won't be making those changes.

@stancl stancl marked this pull request as ready for review January 21, 2025 14:36
@stancl
Copy link
Member Author

stancl commented Jan 21, 2025

Snowflake generator is not being added since the implementation is too app-specific and apps that do use snowflakes would likely want to use a consistent implementation for all models rather than Tenancy rolling its own.

@stancl
Copy link
Member Author

stancl commented Jan 21, 2025

Not sure why pcov is not picking up the coverage here. The method is being executed in the test correctly.

@stancl stancl merged commit 25360f6 into master Jan 21, 2025
11 checks passed
@stancl stancl deleted the improve-id-generators branch January 21, 2025 16:06
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