From ca03daa09f04559dc14cfca23774adf67de7467e Mon Sep 17 00:00:00 2001 From: Lloyd Watkin Date: Tue, 30 Apr 2024 08:59:03 +0100 Subject: [PATCH] Direct `BEGIN` queries to primary database server --- Gemfile.lock | 2 +- lib/janus/query_director.rb | 2 +- lib/janus/version.rb | 2 +- spec/lib/janus/query_director_spec.rb | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28ff842..06bdbc8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - janus-ar (0.14.0) + janus-ar (0.15.1) GEM remote: http://rubygems.org/ diff --git a/lib/janus/query_director.rb b/lib/janus/query_director.rb index 6d1b020..e2aa23e 100644 --- a/lib/janus/query_director.rb +++ b/lib/janus/query_director.rb @@ -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 diff --git a/lib/janus/version.rb b/lib/janus/version.rb index ef0123d..248bd2f 100644 --- a/lib/janus/version.rb +++ b/lib/janus/version.rb @@ -5,7 +5,7 @@ module Janus module VERSION MAJOR = 0 MINOR = 15 - PATCH = 0 + PATCH = 1 PRE = nil def self.to_s diff --git a/spec/lib/janus/query_director_spec.rb b/spec/lib/janus/query_director_spec.rb index c12f4e1..4b36f4d 100644 --- a/spec/lib/janus/query_director_spec.rb +++ b/spec/lib/janus/query_director_spec.rb @@ -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 }