Skip to content
  • Jean Boussier's avatar
    12cc24a7
    Refactor ActiveRecord::QueryLogs hook point · 12cc24a7
    Jean Boussier authored
    Hooking into `execute` and `exec_query` is problematic
    because some adapters like MySQL2 have `exec_query` call `execute`
    which forces QueryLogs to first check wether the comment was already
    applied.
    
    Using a prepended module is also a bit problematic because it
    means it has to be prepended to the "final" adapter classes
    but if the user application has a custom adapter that inherits
    from a built-in one, the built-in one no longer have QueryLogs
    working.
    
    So instead this PR introduce `ActiveRecord.query_transformers`,
    and the adpters are responsible for applying to transformers only
    once.
    12cc24a7
    Refactor ActiveRecord::QueryLogs hook point
    Jean Boussier authored
    Hooking into `execute` and `exec_query` is problematic
    because some adapters like MySQL2 have `exec_query` call `execute`
    which forces QueryLogs to first check wether the comment was already
    applied.
    
    Using a prepended module is also a bit problematic because it
    means it has to be prepended to the "final" adapter classes
    but if the user application has a custom adapter that inherits
    from a built-in one, the built-in one no longer have QueryLogs
    working.
    
    So instead this PR introduce `ActiveRecord.query_transformers`,
    and the adpters are responsible for applying to transformers only
    once.
Loading