janus-ar 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 385d7c8b2d818661697a772e2c32d382bea82e11a01548812d6e0bd50b729eb5
|
4
|
+
data.tar.gz: 3314da59cac901b3d453c763d426ffeacafa98586f7530b8dd52421b185ed968
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a108987d5c2d0fc9daa7de2b0f934a89f03bc877f6b8fc93c49af724e2aa55727b2a9bd912e5727cb91b16676cdf76bc089e8ffcbef9ca4bfd2132acd90623b1
|
7
|
+
data.tar.gz: a4b3fbf3e1b3b9b932454952048441954048ea0571947aa5ede324eb166bf7890bee96e4d0e2d1419cb0b551dc1a19ee47acd04f79e7718d589773e697cdff42
|
data/Gemfile.lock
CHANGED
@@ -32,7 +32,7 @@ module ActiveRecord
|
|
32
32
|
SQL_REPLICA_MATCHERS = [/\A\s*(select|with.+\)\s*select)\s/i].freeze
|
33
33
|
SQL_ALL_MATCHERS = [/\A\s*set\s/i].freeze
|
34
34
|
SQL_SKIP_ALL_MATCHERS = [/\A\s*set\s+local\s/i].freeze
|
35
|
-
WRITE_PREFIXES = %w(INSERT UPDATE DELETE LOCK CREATE GRANT DROP).freeze
|
35
|
+
WRITE_PREFIXES = %w(INSERT UPDATE DELETE LOCK CREATE GRANT DROP ALTER).freeze
|
36
36
|
|
37
37
|
attr_reader :config
|
38
38
|
|
@@ -133,7 +133,7 @@ module ActiveRecord
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def write_query?(sql)
|
136
|
-
WRITE_PREFIXES.include?(sql.split(' ').first)
|
136
|
+
WRITE_PREFIXES.include?(sql.upcase.split(' ').first)
|
137
137
|
end
|
138
138
|
|
139
139
|
def update_config
|
data/lib/janus/version.rb
CHANGED
@@ -16,7 +16,7 @@ RSpec.describe ActiveRecord::ConnectionAdapters::JanusMysql2Adapter do
|
|
16
16
|
}
|
17
17
|
it { expect(described_class::SQL_REPLICA_MATCHERS).to eq([/\A\s*(select|with.+\)\s*select)\s/i]) }
|
18
18
|
it { expect(described_class::SQL_ALL_MATCHERS).to eq([/\A\s*set\s/i]) }
|
19
|
-
it { expect(described_class::WRITE_PREFIXES).to eq %w(INSERT UPDATE DELETE LOCK CREATE GRANT DROP) }
|
19
|
+
it { expect(described_class::WRITE_PREFIXES).to eq %w(INSERT UPDATE DELETE LOCK CREATE GRANT DROP ALTER) }
|
20
20
|
|
21
21
|
let(:database) { 'test' }
|
22
22
|
let(:primary_config) do
|
@@ -121,5 +121,25 @@ RSpec.describe ActiveRecord::ConnectionAdapters::JanusMysql2Adapter do
|
|
121
121
|
expect($query_logger.queries.first).to include '[primary]'
|
122
122
|
end
|
123
123
|
end
|
124
|
+
|
125
|
+
describe 'INSERT' do
|
126
|
+
let(:insert_query) { 'INSERT INTO test_table SET `id` = 5;' }
|
127
|
+
|
128
|
+
before(:each) do
|
129
|
+
create_test_table
|
130
|
+
$query_logger.flush_all
|
131
|
+
Janus::Context.release_all
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'sends INSERT query to primary' do
|
135
|
+
ActiveRecord::Base.connection.execute(insert_query)
|
136
|
+
expect($query_logger.queries.first).to include '[primary]'
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'ignores case when directing queries' do
|
140
|
+
ActiveRecord::Base.connection.execute(insert_query.downcase)
|
141
|
+
expect($query_logger.queries.first).to include '[primary]'
|
142
|
+
end
|
143
|
+
end
|
124
144
|
end
|
125
145
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: janus-ar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lloyd Watkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|