Skip to content

Commit

Permalink
Direct BEGIN queries to primary database server
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydwatkin committed Apr 30, 2024
1 parent 496e6c8 commit ca03daa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
janus-ar (0.14.0)
janus-ar (0.15.1)

GEM
remote: http://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion lib/janus/query_director.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class QueryDirector
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
WRITE_PREFIXES = %w(INSERT UPDATE DELETE LOCK CREATE GRANT DROP ALTER TRUNCATE FLUSH).freeze
WRITE_PREFIXES = %w(INSERT UPDATE DELETE LOCK CREATE GRANT DROP ALTER TRUNCATE BEGIN SAVEPOINT FLUSH).freeze

def initialize(sql, open_transactions)
@_sql = sql
Expand Down
2 changes: 1 addition & 1 deletion lib/janus/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Janus
module VERSION
MAJOR = 0
MINOR = 15
PATCH = 0
PATCH = 1
PRE = nil

def self.to_s
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/janus/query_director_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
it { expect(described_class::SQL_REPLICA_MATCHERS).to eq([/\A\s*(select|with.+\)\s*select)\s/i]) }
it { expect(described_class::SQL_ALL_MATCHERS).to eq([/\A\s*set\s/i]) }
it {
expect(described_class::WRITE_PREFIXES).to eq %w(INSERT UPDATE DELETE LOCK CREATE GRANT DROP ALTER TRUNCATE FLUSH)
expect(described_class::WRITE_PREFIXES).to eq %w(INSERT UPDATE DELETE LOCK CREATE GRANT DROP ALTER TRUNCATE BEGIN
SAVEPOINT FLUSH)
}

it { expect(described_class::ALL).to eq :all }
Expand Down

0 comments on commit ca03daa

Please sign in to comment.