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

Fixup compatibility w/ active_type gem #232

Merged
merged 3 commits into from
Aug 24, 2024

Conversation

ojab
Copy link
Contributor

@ojab ojab commented Aug 23, 2024

Handle anonymous classes (a bit differently than #221) and use .table_exists? on Model instead of Model.connection.
See commit messages for details.
This is arguable ActiveType issue, but why not handle such cases.

Also fixing compat w/ AR-main, also extracted to the separate PR #235 to allow merging separately if needed.

@ojab ojab force-pushed the fixup_active_type branch 2 times, most recently from 3629b24 to a8b733d Compare August 23, 2024 19:51
@ojab ojab changed the title Fixup compatibility w/ active_type` gem Fixup compatibility w/ active_type gem Aug 23, 2024
@ojab ojab force-pushed the fixup_active_type branch 10 times, most recently from 611f384 to a03a776 Compare August 24, 2024 10:33
ojab added 2 commits August 24, 2024 12:41
Rails switched to `sqlite3 >= 2.0` in [0], so workflow fails due to
the current `~> 1.3` constraint. It's quite complicated to make
current gemfiles setup to handle this, because `sqlite3` is not an AR
dependency, but loaded when needed, so we need to edit all the
gemfiles with explicit sqlite3 constraint.
Introduce Appraisal to generate gemfiles, so it's easier to handle.

[0] rails/rails@2976d37
`.const_source_location` raises `NameError` on invalid names, which
means that it's either anonymous class or class name was manually
defined.

Skip such classes.
@ojab ojab force-pushed the fixup_active_type branch 2 times, most recently from 3333c69 to d183486 Compare August 24, 2024 13:18
`ActiveType` is creating ActiveModel-like entities, but backed by
ActiveRecord, mocking DB interactions [0].
Mocking is incomplete and `AbstractAdapter` is used, so
`connection.table_exists?` raises `NotImplementedError`.

Workaround it by using `Model#table_exists?` which also simplifies the
code a bit.

[0] https://github.com/makandra/active_type/blob/main/lib/active_type/no_table.rb
@ojab ojab force-pushed the fixup_active_type branch from d183486 to b3e72dc Compare August 24, 2024 13:19
@ojab ojab marked this pull request as ready for review August 24, 2024 13:23
@djezzzl djezzzl merged commit c3aebe9 into djezzzl:master Aug 24, 2024
8 checks passed
@ojab ojab deleted the fixup_active_type branch August 24, 2024 15:12
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.

2 participants