Skip to content
Discussion options

You must be logged in to vote

Welcome back @jackcb123.

You can find the logic here: https://github.com/Nasdaq/active_record_proxy_adapters/blob/main/lib/active_record_proxy_adapters/primary_replica_proxy.rb#L196C1-L202C8

We don't have a quick way to customize the regexes at the moment but here are a few options you could try:

  • Create a custom adapter and a custom proxy (there's instructions in README for that)
  • Monkey patch the constant SQL_REPLICA_MATCHERS to include any other regex patterns you need
  • Monkey patch method need_primary?(sql_string) directly. Something like this:
      def need_primary?(sql_string)
        return true  if cte_for_write?(sql_string)
        return true  if SQL_PRIMARY_MATCHERS.any?(&match_sql?(sql_string

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mateuscruz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #73 on June 19, 2025 17:38.