Class: Janus::QueryDirector
- Inherits:
-
Object
- Object
- Janus::QueryDirector
- Defined in:
- lib/janus-ar/query_director.rb
Constant Summary collapse
- ALL =
:all- REPLICA =
:replica- PRIMARY =
:primary- SQL_PRIMARY_MATCHERS =
[ /\A\s*select.+for update\Z/i, /select.+lock in share mode\Z/i, /\A\s*select.+(nextval|currval|lastval|get_lock|release_lock|pg_advisory_lock|pg_advisory_unlock)\(/i, /\A\s*show/i ].freeze
- SQL_REPLICA_MATCHERS =
[/\A\s*(select|with.+\)\s*select)\s/i].freeze
- SQL_ALL_MATCHERS =
[/\A\s*set\s/i].freeze
- SQL_SKIP_ALL_MATCHERS =
[/\A\s*set\s+local\s/i].freeze
- LEADING_NOISE =
Leading whitespace and SQL comments are stripped before matching so that an annotated statement (e.g. ‘/* app:web */ INSERT …`) is classified by the statement itself rather than by the comment.
%r{\A(?:\s+|/\*.*?\*/|--[^\n]*(?:\n|\z)|\#[^\n]*(?:\n|\z))+}m
Instance Method Summary collapse
-
#initialize(sql, open_transactions) ⇒ QueryDirector
constructor
A new instance of QueryDirector.
- #where_to_send? ⇒ Boolean
Constructor Details
#initialize(sql, open_transactions) ⇒ QueryDirector
Returns a new instance of QueryDirector.
22 23 24 25 |
# File 'lib/janus-ar/query_director.rb', line 22 def initialize(sql, open_transactions) @_sql = sql @_open_transactions = open_transactions end |