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

Deprecations Warning Rails 6 #78

Closed

Conversation

vladvinnikov
Copy link

@vladvinnikov vladvinnikov commented Mar 4, 2019

When run specs for rails 5.2.x i receive

DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s). 

This is because i have complex plain SQL for ordering, and now order in rails must be encoded with Arel.sql to process unsafe sql.

See https://github.com/rails/rails/commit/310c3a8f2d043f3d00d3f703052a1e160430a2c2

When run specs for rails 5.2.x i receive DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s). This is because i have complex plain SQL for ordering, and now order in rails must be encoded with Arel.sql
@felixbuenemann
Copy link
Collaborator

This won't work as is, because you can also pass stuff like order: { id: :desc }.

The easiest solution would be to check if configuration[:order].respond_to? :to_sql and then call to_sql and wrap the result in Arel.sql. However that will cause a database connection to be established during class load and that is bad.

I'll have to think about this problem.

@felixbuenemann
Copy link
Collaborator

I've merged #79 which should address this problem.

You should wrap the :order option in Arel.sql() yourself, because acts_as_tree tries to support all valid ways to support order in ActiveRecord.

I'm currently doing some maintenance and will release a new gem with the changes soon.

@felixbuenemann
Copy link
Collaborator

@vladvinnikov acts_as_tree 2.9.0 has been released on rubygems.

@vladvinnikov
Copy link
Author

@vladvinnikov acts_as_tree 2.9.0 has been released on rubygems.

Great! Works as expected without warnings (i use Arel.sql as and order param).

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