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

Rails/ThreeStateBooleanColumn parse exception when table/column is dynamic #1010

Closed
vlad-pisanov opened this issue May 21, 2023 · 0 comments · Fixed by #1013
Closed

Rails/ThreeStateBooleanColumn parse exception when table/column is dynamic #1010

vlad-pisanov opened this issue May 21, 2023 · 0 comments · Fixed by #1013
Labels
bug Something isn't working

Comments

@vlad-pisanov
Copy link
Contributor

Currently, Rails/ThreeStateBooleanColumn assumes that the table name and the column name are literals. Passing in a variable or a constant raises a parse exception:

An error occurred while Rails/ThreeStateBooleanColumn cop was inspecting
db/migrate/test.rb:42:6.
undefined method `value' for s(:const, nil, :column):RuboCop::AST::ConstNode

Sample migration:

def up
   table  = :users
   column = :is_admin

   add_column :users, :is_admin, :boolean   # ✔️
   add_column table,  :is_admin, :boolean   # 💥parse exception
   add_column :users,  column,   :boolean   # 💥parse exception
end

(version rubocop-rails-2.19.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants