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

Don't crash on rails < 7 #1074

Merged
merged 1 commit into from
Jul 29, 2022
Merged

Don't crash on rails < 7 #1074

merged 1 commit into from
Jul 29, 2022

Conversation

fsateler
Copy link
Contributor

@fsateler fsateler commented Jul 22, 2022

The method subtype was made public in rails 7, but it did exist previously so we can use it via send.

Motivation

With rails < 7, tapioca dsl crashes with: lib/tapioca/dsl/helpers/active_record_column_type_helper.rb:122:in 'enum_setter_type': private method 'subtype' called for #<ActiveRecord::Enum::EnumType:0x000055c8a8aefb70> (NoMethodError)

Implementation

subtype was not public in rails 6, but it did exist since at least 5.0 https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/enum.rb#L143

Tests

No idea how to add a test for this.

The method `subtype` was made public in rails 7, but it did exist previously so we can use it via `send`.
@fsateler fsateler requested a review from a team as a code owner July 22, 2022 17:14
@paracycle paracycle merged commit 6821598 into Shopify:main Jul 29, 2022
@rafaelfranca
Copy link
Member

I don't see a failure when I run tapioca against Rails 6.1 before this patch. Is this helper being tested?

@rafaelfranca
Copy link
Member

Ah, found it. It is because the enum definition doesn't work in Rails 6.1, so I had to change that before seeing this failure.

@fsateler fsateler deleted the patch-1 branch July 29, 2022 19:08
@paracycle paracycle added the backported Backported to stable branch label Aug 22, 2022
paracycle added a commit that referenced this pull request Aug 22, 2022
@shopify-shipit shopify-shipit bot temporarily deployed to production August 31, 2022 14:40 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Backported to stable branch bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants