activerecord-pedantmysql2-adapter 1.3.0 → 1.4.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 +4 -4
- data/.github/workflows/ci.yml +2 -5
- data/activerecord-pedantmysql2-adapter.gemspec +1 -1
- data/gemfiles/{Gemfile.activerecord-6.0 → Gemfile.activerecord-7.0} +1 -1
- data/lib/active_record/connection_adapters/pedant_mysql2_adapter.rb +6 -3
- data/lib/pedant_mysql2/version.rb +1 -1
- data/lib/pedant_mysql2.rb +5 -3
- data/spec/adapter_spec.rb +7 -2
- data/spec/spec_helper.rb +1 -9
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edb5734c15054a4f6e3d985cad3bf2932cb923d5c3c9f9daa0e846dd43a587a6
|
4
|
+
data.tar.gz: 70c44fec9acff6556b13729d54e2004bbe98653975d11b69654bb99b3ffd9d62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f21453993e5cbe025c65e876de54bedb53082db01ff5551da0e17b902faa48f37fff20cd3e49ec5920038a835339d4e36de0d9570bfe925d4e5577c14c402862
|
7
|
+
data.tar.gz: 830f4252036dd996c2ce76dd6d8f624d324854c27382bc706a8efa2c85c5d080b0dd8f187a4c3654f8e8932128e3f30ecf183573554f181bdcd9ff580e3a9292
|
data/.github/workflows/ci.yml
CHANGED
@@ -8,11 +8,8 @@ jobs:
|
|
8
8
|
name: Ruby ${{ matrix.ruby }} / Active Record ${{ matrix.activerecord }}
|
9
9
|
strategy:
|
10
10
|
matrix:
|
11
|
-
ruby: ['2.
|
12
|
-
activerecord: ['6.
|
13
|
-
exclude:
|
14
|
-
- ruby: '2.6'
|
15
|
-
activerecord: 'edge'
|
11
|
+
ruby: ['2.7', '3.0', '3.1']
|
12
|
+
activerecord: ['6.1', '7.0', 'edge']
|
16
13
|
env:
|
17
14
|
BUNDLE_GEMFILE: gemfiles/Gemfile.activerecord-${{ matrix.activerecord }}
|
18
15
|
steps:
|
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_dependency 'activerecord', '>= 6.0'
|
26
26
|
spec.add_dependency 'mysql2', '>= 0.3.12'
|
27
|
+
|
27
28
|
spec.add_development_dependency 'bundler'
|
28
29
|
spec.add_development_dependency 'rake'
|
29
30
|
spec.add_development_dependency 'rspec', '>= 3.0'
|
30
31
|
spec.add_development_dependency 'rspec-its'
|
31
|
-
spec.add_development_dependency 'coveralls'
|
32
32
|
end
|
@@ -76,10 +76,13 @@ class ActiveRecord::ConnectionAdapters::PedantMysql2Adapter < ActiveRecord::Conn
|
|
76
76
|
private
|
77
77
|
|
78
78
|
def log_warnings(sql)
|
79
|
-
|
79
|
+
# support for https://github.com/rails/rails/commit/d86fd6415c0dfce6fadb77e74696cf728e5eb76b
|
80
|
+
connection = instance_variable_defined?(:@raw_connection) ? @raw_connection : @connection
|
80
81
|
|
81
|
-
|
82
|
-
|
82
|
+
return unless connection.warning_count > 0
|
83
|
+
|
84
|
+
@affected_rows_before_logging = connection.affected_rows
|
85
|
+
result = connection.query('SHOW WARNINGS')
|
83
86
|
|
84
87
|
result.each do |level, code, message|
|
85
88
|
warning = MysqlWarning.new(message, code, level, sql)
|
data/lib/pedant_mysql2.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PedantMysql2
|
2
4
|
class << self
|
3
5
|
def capture_warnings
|
@@ -46,11 +48,11 @@ module PedantMysql2
|
|
46
48
|
end
|
47
49
|
|
48
50
|
def ignored?(warning)
|
49
|
-
whitelist.any? { |matcher| warning.message.match?(matcher) }
|
51
|
+
note_warning?(warning) || whitelist.any? { |matcher| warning.message.match?(matcher) }
|
50
52
|
end
|
51
53
|
|
52
|
-
def
|
53
|
-
warning.
|
54
|
+
def note_warning?(warning)
|
55
|
+
warning.level == "Note"
|
54
56
|
end
|
55
57
|
|
56
58
|
def setup_capture
|
data/spec/adapter_spec.rb
CHANGED
@@ -8,7 +8,6 @@ describe PedantMysql2 do
|
|
8
8
|
PedantMysql2.raise_warnings!
|
9
9
|
PedantMysql2.instance_variable_set(:@whitelist, nil)
|
10
10
|
PedantMysql2.ignore(/They will be merged with strict mode in a future release/)
|
11
|
-
connection.execute('SET SESSION binlog_format = "STATEMENT"')
|
12
11
|
if connection.execute('SHOW TABLES LIKE "comment"').size == 0
|
13
12
|
connection.execute('CREATE TABLE comment (id int)')
|
14
13
|
end
|
@@ -43,12 +42,18 @@ describe PedantMysql2 do
|
|
43
42
|
}.to raise_error(MysqlWarning, "Truncated incorrect DOUBLE value: 'foo'")
|
44
43
|
end
|
45
44
|
|
46
|
-
it 'does not raise when warning
|
45
|
+
it 'does not raise when warning is a Note level warning e.g. unexisting table' do
|
47
46
|
expect {
|
48
47
|
execute_with_warning('DROP TABLE IF EXISTS `example_table`')
|
49
48
|
}.to_not raise_error
|
50
49
|
end
|
51
50
|
|
51
|
+
it 'does not raise when warning is a Note level warning e.g. EXPLAIN queries' do
|
52
|
+
expect {
|
53
|
+
execute_with_warning('EXPLAIN SELECT 1')
|
54
|
+
}.to_not raise_error
|
55
|
+
end
|
56
|
+
|
52
57
|
it 'can have a whitelist of warnings' do
|
53
58
|
PedantMysql2.ignore(/Truncated incorrect DOUBLE value/i)
|
54
59
|
expect {
|
data/spec/spec_helper.rb
CHANGED
@@ -2,14 +2,6 @@ lib = File.expand_path('../lib', __FILE__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
4
|
require 'rspec/its'
|
5
|
-
require 'simplecov'
|
6
|
-
require 'coveralls'
|
7
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
8
|
-
SimpleCov::Formatter::HTMLFormatter,
|
9
|
-
Coveralls::SimpleCov::Formatter
|
10
|
-
])
|
11
|
-
SimpleCov.start
|
12
|
-
|
13
5
|
require 'activerecord-pedantmysql2-adapter'
|
14
6
|
|
15
7
|
module TestSupport
|
@@ -18,7 +10,7 @@ module TestSupport
|
|
18
10
|
'database' => 'pedant_mysql2_test',
|
19
11
|
'username' => 'root',
|
20
12
|
'password' => ENV['CI'] ? 'root' : nil,
|
21
|
-
'encoding' => '
|
13
|
+
'encoding' => 'utf8mb4',
|
22
14
|
'host' => 'localhost',
|
23
15
|
'strict' => false,
|
24
16
|
'pool' => 5,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-pedantmysql2-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: coveralls
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
97
|
description: Gives a hook on MySQL warnings that allow you to either raise or log
|
112
98
|
them.
|
113
99
|
email:
|
@@ -124,8 +110,8 @@ files:
|
|
124
110
|
- README.md
|
125
111
|
- Rakefile
|
126
112
|
- activerecord-pedantmysql2-adapter.gemspec
|
127
|
-
- gemfiles/Gemfile.activerecord-6.0
|
128
113
|
- gemfiles/Gemfile.activerecord-6.1
|
114
|
+
- gemfiles/Gemfile.activerecord-7.0
|
129
115
|
- gemfiles/Gemfile.activerecord-edge
|
130
116
|
- lib/active_record/connection_adapters/pedant_mysql2_adapter.rb
|
131
117
|
- lib/activerecord-pedantmysql2-adapter.rb
|
@@ -155,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
141
|
- !ruby/object:Gem::Version
|
156
142
|
version: '0'
|
157
143
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.3.3
|
159
145
|
signing_key:
|
160
146
|
specification_version: 4
|
161
147
|
summary: ActiveRecord adapter for MySQL that report warnings.
|