Skip to content
  • Jean Boussier's avatar
    8e6a5dec
    Relation#where build BoundSqlLiteral rather than eagerly interpolate · 8e6a5dec
    Jean Boussier authored
    Ref: https://github.com/rails/rails/pull/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.
    8e6a5dec
    Relation#where build BoundSqlLiteral rather than eagerly interpolate
    Jean Boussier authored
    Ref: https://github.com/rails/rails/pull/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.
Loading