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

Use AR Arel table to type cast booleans in order to avoid deprecation warning #421

Merged
merged 1 commit into from
Jan 6, 2021

Conversation

thom-oman
Copy link
Contributor

@thom-oman thom-oman commented Dec 16, 2020

DEPRECATION WARNING: Passing a column to `quote` has been deprecated. It is only used for type casting, which should be handled elsewhere. See https://github.com/rails/arel/commit/6160bfbda1d1781c3b08a33ec4955f170e95be11 for more information. (called from update_most_recents at /Users/eproulx/code/statesman/lib/statesman/adapters/active_record.rb:144)
Arel performing automatic type casting is deprecated, and will be removed in Arel 8.0. If you are seeing this, it is because you are manually passing a value to an Arel predicate, and the `Arel::Table` object was constructed manually. The easiest way to remove this warning is to use an `Arel::Table` object returned from calling `arel_table` on an ActiveRecord::Base subclass.

If you're certain the value is already of the right type, change `attribute.eq(value)` to `attribute.eq(Arel::Nodes::Quoted.new(value))` (you will be able to remove that in Arel 8.0, it is only required to silence this deprecation warning).

You can also silence this warning globally by setting `$arel_silence_type_casting_deprecation` to `true`. (Do NOT do this if you are a library author)

If you are passing user input to a predicate, you must either give an appropriate type caster object to the `Arel::Table`, or manually cast the value before passing it to Arel.

also

DEPRECATION WARNING: Passing a column to `quote` has been deprecated. It
is only used for type casting, which should be handled elsewhere.

#403

@thom-oman thom-oman marked this pull request as ready for review December 16, 2020 16:06
@thom-oman thom-oman changed the title Use Arel::Nodes::Quoted to avoid deprecation warning Use AR Arel table to type cast booleans in order to avoid deprecation warning Dec 16, 2020
@thom-oman thom-oman force-pushed the thom/fix_deprecation_warning branch 4 times, most recently from 55e48c5 to ab4c373 Compare December 17, 2020 14:22
… warning

```
DEPRECATION WARNING: Passing a column to `quote` has been deprecated. It
is only used for type casting, which should be handled elsewhere.
```
Copy link
Contributor

@danwakefield danwakefield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea if this messes up anyone using string instead of bool as a column type.
Major bump to avoid the version breaking them?

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