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

Relation#where build BoundSqlLiteral rather than eagerly interpolate #51139

Merged
merged 1 commit into from Feb 21, 2024

Commits on Feb 21, 2024

  1. Relation#where build BoundSqlLiteral rather than eagerly interpolate

    Ref: rails#50793
    
    To make not caching connection checkout viable, we need to reduced
    the amount of places where we need a connection.
    
    Once big source of this is query/relation building, where in many
    cases it eagerly quote and interpolation bound values in SQL fragments.
    
    Doing this requires an active connection because both MySQL and Postgres
    may quote values differently based on the connection settings.
    
    Instead of eagerly doing all this, we can instead just insert these
    as bound values in the Arel AST. For adapters with prepared statements
    this is better anyway as it will avoid leaking statements, and for those
    that don't support it, it will simply delay the quoting to just
    before the query is executed.
    
    However, the `%` API (`where("title = %s", something)`) can't realistically
    be fixed this way, but I don't see much value in it and it probably should
    be deprecated and removed.
    byroot committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    8e6a5de View commit details
    Browse the repository at this point in the history