Custom Sql Patterns #74
|
Hi! We use a lot of sql patterns where we have comments at the beginning of custom queries in blocks or in-line, use ctes like 'WITH' , etc. Is it possible to customize the sql checker that decides whether to use the primary or replica? If not, do you mind me asking where that occurs within your repo? This is what we currently use with makara if that's helpful! Hoping to make the switch to yours (as of course makara is no longer maintained) CUSTOM_SQL_REPLICA_MATCHERS = [ |
Replies: 2 comments
|
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:
|
|
This issue was actually related to #78 so can be closed. |
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:
SQL_REPLICA_MATCHERSto include any other regex patterns you needneed_primary?(sql_string)directly. Something like this: