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

Make it possible to extend list of id types for ActiveRecord relations #1967

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

paracycle
Copy link
Member

@paracycle paracycle commented Jul 22, 2024

Motivation

Fixes the root problem specified in #1965

Implementation

By moving the list of id types to a constant, we are now making it possible to extend the list of id types for ActiveRecord relations in gem or application level "compilers".

All that a "compiler" needs to do is to read the list of id types from the Tapioca::DSL::Compilers::ActiveRecordRelations::ID_TYPES constant, add the new id type to the list and then assign the result back to Tapioca::DSL::Compilers::ActiveRecordRelations::ID_TYPES.

Tests

Added a DSL CLI test to show how "compilers" can change the behaviour of the AR relations compiler.

By moving the list of id types to a constant, we are now making it possible to extend the list of id types for ActiveRecord relations in gem or application level "compilers".

All that a "compiler" needs to do is to read the list of id types from the `Tapioca::DSL::Compilers::ActiveRecordRelations::ID_TYPES` constant, add the new id type to the list and then assign the result back to `Tapioca::DSL::Compilers::ActiveRecordRelations::ID_TYPES`.
@paracycle paracycle enabled auto-merge July 22, 2024 19:44
@paracycle paracycle merged commit 713d804 into main Jul 22, 2024
29 checks passed
@paracycle paracycle deleted the uk-make-id-types-flexible branch July 22, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants