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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fb193accc432a0fed85a527c520afef1f5bf3c43
4
- data.tar.gz: b11fe06882e5086459d26f52cd59bcfb6ead0327
2
+ SHA256:
3
+ metadata.gz: 0cdc8bc77345e0ed3428828757da42af2180846edbb81327efbad5a0ab28a48e
4
+ data.tar.gz: 6e90b36c37754b0accdaac56ff69d125b61262f7d79be7884fa79afd835dc010
5
5
  SHA512:
6
- metadata.gz: e8146d26e36fa99f37a3c08277da4db95210a3fabc0ad6764dde8de9cefa3751ac1a4f79ee97733cc058ab704878100459c7dc3f5c95b612c803c5a16b5f1fd8
7
- data.tar.gz: f950e21b77652402beb3ebd2e7d5786f59f47d97a1568120d7fe19e6b9a84abccdb0fb9f4c53ff0c3eae82f2b4222ebf6a2fab5198128bd69343824c15150027
6
+ metadata.gz: 20edfa621dd97dbd80a2b3a5cc3f31711a85074228a5a848b4bc9c987ace3e5d92ad979995560b220526e572aea9f6c3e586e89825e8386fbab6bb4d68578a72
7
+ data.tar.gz: 79fa48c21ae537ef22c88692c59ea5eaa6332953bc68f3666134373043b1eeb4d1e1e86160b4a7cb6442a0bf757cd9af206026da145460c9c9058ab75b417ec2
@@ -1,27 +1,24 @@
1
+ services:
2
+ - mysql
3
+
1
4
  rvm:
2
- - 1.9.3
3
- - 2.0.0
4
- - 2.1.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.activerecord32
10
- - Gemfile.activerecord40
11
- - Gemfile.activerecord41
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: 1.9.3
18
- gemfile: Gemfile.activerecord50
19
- - rvm: 2.0.0
20
- gemfile: Gemfile.activerecord50
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 easilly whitelist some types of warnings:
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', '>= 3.2'
25
+ spec.add_dependency 'activerecord', '>= 5.0'
22
26
  spec.add_dependency 'mysql2', '>= 0.3.12'
23
- spec.add_development_dependency 'bundler', '~> 1.5'
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'
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '..'
3
+
4
+ gem 'activerecord', github: 'rails/rails', branch: 'master'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '..'
3
+
4
+ gem 'activerecord', '~> 5.2.0'
5
+ gem 'mysql2'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '..'
3
+
4
+ gem 'activerecord', '~> 6.0.0'
5
+ gem 'mysql2'
@@ -2,24 +2,44 @@ require 'active_record/connection_adapters/mysql2_adapter'
2
2
 
3
3
  module ActiveRecord
4
4
  module ConnectionHandling
5
- def pedant_mysql2_connection(config)
6
- config = config.symbolize_keys
7
-
8
- config[:username] = 'root' if config[:username].nil?
9
-
10
- if Mysql2::Client.const_defined? :FOUND_ROWS
11
- config[:flags] = Mysql2::Client::FOUND_ROWS
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
- client = Mysql2::Client.new(config)
15
-
16
- options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0]
17
- ActiveRecord::ConnectionAdapters::PedantMysql2Adapter.new(client, logger, options, config)
18
- rescue Mysql2::Error => error
19
- if error.message.include?("Unknown database") && defined?(ActiveRecord::NoDatabaseError)
20
- raise ActiveRecord::NoDatabaseError.new(error.message)
21
- else
22
- raise
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
@@ -46,11 +46,11 @@ module PedantMysql2
46
46
  end
47
47
 
48
48
  def ignored?(warning)
49
- whitelist.any? { |matcher| matcher =~ warning.message } || drop_table_warning(warning)
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 =~ /\ADROP TABLE IF EXISTS/ || warning.message =~ /\AUnknown table/
53
+ warning.query.match?(/\ADROP TABLE IF EXISTS/) || warning.message.match?(/\AUnknown table/)
54
54
  end
55
55
 
56
56
  def setup_capture
@@ -1,3 +1,3 @@
1
1
  module PedantMysql2
2
- VERSION = '1.1.3'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -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)')
@@ -1,11 +1,9 @@
1
- ActiveRecord::Base.configurations = {
2
- 'test' => {
3
- adapter: 'pedant_mysql2',
4
- database: 'pedant_mysql2_test',
5
- username: 'travis',
6
- encoding: 'utf8',
7
- strict: false,
8
- pool: 5,
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.1.3
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: 2017-07-27 00:00:00.000000000 Z
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: '3.2'
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: '3.2'
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: '1.5'
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: '1.5'
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: '0'
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
- rubyforge_project:
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.
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'activerecord', '~> 3.2.0'
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'activerecord', '~> 4.0.0'
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'activerecord', '~> 4.1.0'
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'activerecord', '~> 4.2.0.rc1'
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'activerecord', '~> 5.0.0'
@@ -1,2 +0,0 @@
1
- fetch:
2
- - fetch-gem-version activerecord-pedantmysql2-adapter Shopify/activerecord-pedantmysql2-adapter