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

Update Movie.default_list_order scope with safe SQL #344

Open
lortza opened this issue Jan 5, 2023 · 0 comments
Open

Update Movie.default_list_order scope with safe SQL #344

lortza opened this issue Jan 5, 2023 · 0 comments

Comments

@lortza
Copy link
Collaborator

lortza commented Jan 5, 2023

I am seeing this warning in our spec output and we'll need to address it before upgrading to rails 6 (or ideally right away).

DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "CAST(listings.created_at as DATE) desc, listings.priority desc". Non-attribute arguments will be disallowed in Rails 6.0. This method should not be called with user-provided values, such as request parameters or model attributes. Known-safe values can be passed by wrapping them in Arel.sql(). (called from block in class:Movie at /app/models/movie.rb:29)

# /app/models/movie.rb:29

 scope :default_list_order, -> (list) do
    list.movies.order('CAST(listings.created_at as DATE) desc, listings.priority desc')
  end
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

No branches or pull requests

1 participant