activerecord-pedantmysql2-adapter 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +14 -17
- data/README.md +1 -1
- data/activerecord-pedantmysql2-adapter.gemspec +6 -2
- data/gemfiles/Gemfile.activerecord-edge +4 -0
- data/gemfiles/Gemfile.activerecord52 +5 -0
- data/gemfiles/Gemfile.activerecord60 +5 -0
- data/lib/active_record/connection_adapters/pedant_mysql2_adapter.rb +37 -17
- data/lib/pedant_mysql2.rb +2 -2
- data/lib/pedant_mysql2/version.rb +1 -1
- data/spec/adapter_spec.rb +1 -0
- data/spec/support/database.rb +9 -11
- metadata +15 -18
- data/Gemfile.activerecord32 +0 -4
- data/Gemfile.activerecord40 +0 -4
- data/Gemfile.activerecord41 +0 -4
- data/Gemfile.activerecord42 +0 -4
- data/Gemfile.activerecord50 +0 -4
- data/shipit.rubygems.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0cdc8bc77345e0ed3428828757da42af2180846edbb81327efbad5a0ab28a48e
|
4
|
+
data.tar.gz: 6e90b36c37754b0accdaac56ff69d125b61262f7d79be7884fa79afd835dc010
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20edfa621dd97dbd80a2b3a5cc3f31711a85074228a5a848b4bc9c987ace3e5d92ad979995560b220526e572aea9f6c3e586e89825e8386fbab6bb4d68578a72
|
7
|
+
data.tar.gz: 79fa48c21ae537ef22c88692c59ea5eaa6332953bc68f3666134373043b1eeb4d1e1e86160b4a7cb6442a0bf757cd9af206026da145460c9c9058ab75b417ec2
|
data/.travis.yml
CHANGED
@@ -1,27 +1,24 @@
|
|
1
|
+
services:
|
2
|
+
- mysql
|
3
|
+
|
1
4
|
rvm:
|
2
|
-
-
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.2.2
|
6
|
-
- 2.3.0
|
5
|
+
- '2.5'
|
6
|
+
- '2.6'
|
7
|
+
- '2.7'
|
7
8
|
|
8
9
|
gemfile:
|
9
|
-
- Gemfile.
|
10
|
-
- Gemfile.
|
11
|
-
- Gemfile.
|
12
|
-
- Gemfile.activerecord42
|
13
|
-
- Gemfile.activerecord50
|
10
|
+
- gemfiles/Gemfile.activerecord52
|
11
|
+
- gemfiles/Gemfile.activerecord60
|
12
|
+
- gemfiles/Gemfile.activerecord-edge
|
14
13
|
|
15
14
|
matrix:
|
16
15
|
exclude:
|
17
|
-
- rvm:
|
18
|
-
gemfile: Gemfile.
|
19
|
-
- rvm: 2.
|
20
|
-
gemfile: Gemfile.
|
21
|
-
- rvm: 2.1.2
|
22
|
-
gemfile: Gemfile.activerecord50
|
16
|
+
- rvm: '2.5'
|
17
|
+
gemfile: gemfiles/Gemfile.activerecord-edge
|
18
|
+
- rvm: '2.6'
|
19
|
+
gemfile: gemfiles/Gemfile.activerecord-edge
|
23
20
|
|
24
21
|
before_script:
|
25
|
-
- mysql -e 'create database pedant_mysql2_test;'
|
22
|
+
- mysql -u root -h 127.0.0.1 -e 'create database pedant_mysql2_test;'
|
26
23
|
|
27
24
|
sudo: false
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ and to restore it to raising warnings as errors:
|
|
52
52
|
PedantMysql2.raise_warnings!
|
53
53
|
```
|
54
54
|
|
55
|
-
You can
|
55
|
+
You can easily whitelist some types of warnings:
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
PedantMysql2.ignore(/Some warning I don't care about/i)
|
@@ -13,14 +13,18 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = 'https://github.com/Shopify/activerecord-pedantmysql2-adapter'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
17
|
+
|
18
|
+
spec.required_ruby_version = '>= 2.2.2'
|
19
|
+
|
16
20
|
spec.files = `git ls-files -z`.split("\x0")
|
17
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
23
|
spec.require_paths = ['lib']
|
20
24
|
|
21
|
-
spec.add_dependency 'activerecord', '>=
|
25
|
+
spec.add_dependency 'activerecord', '>= 5.0'
|
22
26
|
spec.add_dependency 'mysql2', '>= 0.3.12'
|
23
|
-
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'bundler'
|
24
28
|
spec.add_development_dependency 'rake'
|
25
29
|
spec.add_development_dependency 'rspec', '>= 3.0'
|
26
30
|
spec.add_development_dependency 'rspec-its'
|
@@ -2,24 +2,44 @@ require 'active_record/connection_adapters/mysql2_adapter'
|
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
4
|
module ConnectionHandling
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
if ConnectionAdapters::Mysql2Adapter.respond_to?(:new_client)
|
6
|
+
def pedant_mysql2_connection(config)
|
7
|
+
config = config.symbolize_keys
|
8
|
+
config[:flags] ||= 0
|
9
|
+
|
10
|
+
if config[:flags].kind_of? Array
|
11
|
+
config[:flags].push "FOUND_ROWS"
|
12
|
+
else
|
13
|
+
config[:flags] |= Mysql2::Client::FOUND_ROWS
|
14
|
+
end
|
15
|
+
|
16
|
+
ConnectionAdapters::PedantMysql2Adapter.new(
|
17
|
+
ConnectionAdapters::Mysql2Adapter.new_client(config),
|
18
|
+
logger,
|
19
|
+
nil,
|
20
|
+
config,
|
21
|
+
)
|
12
22
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
else
|
24
|
+
def pedant_mysql2_connection(config)
|
25
|
+
config = config.symbolize_keys
|
26
|
+
|
27
|
+
config[:username] = 'root' if config[:username].nil?
|
28
|
+
|
29
|
+
if Mysql2::Client.const_defined? :FOUND_ROWS
|
30
|
+
config[:flags] = Mysql2::Client::FOUND_ROWS
|
31
|
+
end
|
32
|
+
|
33
|
+
client = Mysql2::Client.new(config)
|
34
|
+
|
35
|
+
options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0]
|
36
|
+
ActiveRecord::ConnectionAdapters::PedantMysql2Adapter.new(client, logger, options, config)
|
37
|
+
rescue Mysql2::Error => error
|
38
|
+
if error.message.include?("Unknown database") && defined?(ActiveRecord::NoDatabaseError)
|
39
|
+
raise ActiveRecord::NoDatabaseError.new(error.message)
|
40
|
+
else
|
41
|
+
raise
|
42
|
+
end
|
23
43
|
end
|
24
44
|
end
|
25
45
|
end
|
data/lib/pedant_mysql2.rb
CHANGED
@@ -46,11 +46,11 @@ module PedantMysql2
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def ignored?(warning)
|
49
|
-
whitelist.any? { |matcher|
|
49
|
+
whitelist.any? { |matcher| warning.message.match?(matcher) } || drop_table_warning(warning)
|
50
50
|
end
|
51
51
|
|
52
52
|
def drop_table_warning(warning)
|
53
|
-
warning.query
|
53
|
+
warning.query.match?(/\ADROP TABLE IF EXISTS/) || warning.message.match?(/\AUnknown table/)
|
54
54
|
end
|
55
55
|
|
56
56
|
def setup_capture
|
data/spec/adapter_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe PedantMysql2 do
|
|
7
7
|
before :each do
|
8
8
|
PedantMysql2.raise_warnings!
|
9
9
|
PedantMysql2.instance_variable_set(:@whitelist, nil)
|
10
|
+
PedantMysql2.ignore(/They will be merged with strict mode in a future release/)
|
10
11
|
connection.execute('SET SESSION binlog_format = "STATEMENT"')
|
11
12
|
if connection.execute('SHOW TABLES LIKE "comment"').size == 0
|
12
13
|
connection.execute('CREATE TABLE comment (id int)')
|
data/spec/support/database.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
ActiveRecord::Base.
|
2
|
-
'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
}
|
11
|
-
ActiveRecord::Base.establish_connection(:test)
|
1
|
+
ActiveRecord::Base.establish_connection(
|
2
|
+
'adapter' => 'pedant_mysql2',
|
3
|
+
'database' => 'pedant_mysql2_test',
|
4
|
+
'username' => 'root',
|
5
|
+
'encoding' => 'utf8',
|
6
|
+
'host' => 'localhost',
|
7
|
+
'strict' => false,
|
8
|
+
'pool' => 5,
|
9
|
+
)
|
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.2.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: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mysql2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,20 +120,17 @@ files:
|
|
120
120
|
- ".rspec"
|
121
121
|
- ".travis.yml"
|
122
122
|
- Gemfile
|
123
|
-
- Gemfile.activerecord32
|
124
|
-
- Gemfile.activerecord40
|
125
|
-
- Gemfile.activerecord41
|
126
|
-
- Gemfile.activerecord42
|
127
|
-
- Gemfile.activerecord50
|
128
123
|
- LICENSE.txt
|
129
124
|
- README.md
|
130
125
|
- Rakefile
|
131
126
|
- activerecord-pedantmysql2-adapter.gemspec
|
127
|
+
- gemfiles/Gemfile.activerecord-edge
|
128
|
+
- gemfiles/Gemfile.activerecord52
|
129
|
+
- gemfiles/Gemfile.activerecord60
|
132
130
|
- lib/active_record/connection_adapters/pedant_mysql2_adapter.rb
|
133
131
|
- lib/activerecord-pedantmysql2-adapter.rb
|
134
132
|
- lib/pedant_mysql2.rb
|
135
133
|
- lib/pedant_mysql2/version.rb
|
136
|
-
- shipit.rubygems.yml
|
137
134
|
- spec/adapter_spec.rb
|
138
135
|
- spec/connection_spec.rb
|
139
136
|
- spec/spec_helper.rb
|
@@ -141,7 +138,8 @@ files:
|
|
141
138
|
homepage: https://github.com/Shopify/activerecord-pedantmysql2-adapter
|
142
139
|
licenses:
|
143
140
|
- MIT
|
144
|
-
metadata:
|
141
|
+
metadata:
|
142
|
+
allowed_push_host: https://rubygems.org
|
145
143
|
post_install_message:
|
146
144
|
rdoc_options: []
|
147
145
|
require_paths:
|
@@ -150,15 +148,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
148
|
requirements:
|
151
149
|
- - ">="
|
152
150
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
151
|
+
version: 2.2.2
|
154
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
153
|
requirements:
|
156
154
|
- - ">="
|
157
155
|
- !ruby/object:Gem::Version
|
158
156
|
version: '0'
|
159
157
|
requirements: []
|
160
|
-
|
161
|
-
rubygems_version: 2.5.2
|
158
|
+
rubygems_version: 3.0.3
|
162
159
|
signing_key:
|
163
160
|
specification_version: 4
|
164
161
|
summary: ActiveRecord adapter for MySQL that report warnings.
|
data/Gemfile.activerecord32
DELETED
data/Gemfile.activerecord40
DELETED
data/Gemfile.activerecord41
DELETED
data/Gemfile.activerecord42
DELETED
data/Gemfile.activerecord50
DELETED
data/shipit.rubygems.yml
DELETED