activerecord-mysql-index-hint 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: b6ed09ffc9402615f78570a17a7c6b71dd16ef2c
4
- data.tar.gz: beecd68ecbf4d2787669ffb0f1395309954a85e1
3
+ metadata.gz: f7191260fbe07cc9cb7cfcfb9b83b984e2b28ccd
4
+ data.tar.gz: 05eaa9aa8ddc2190ce7d408af6a4ee1bf562dd34
5
5
  SHA512:
6
- metadata.gz: 9e830a2a518533a98dfcd1792c4bed14d2745fdfe64766f6b7387d1fa7057a93790aa832b641e1b019b1783208248fbe6a8026987c10a043fbf09060ddb5f57c
7
- data.tar.gz: b6ca8fcd39cc51ce292105933a5a8f071d3628e4b3309bd74d22b20b5d102b509fa6d181a73dcec8e01346810c64688beb3418068f18b8dfc24cc9214718c05c
6
+ metadata.gz: 576b2f9b945d6fc3f43becf70b69847d6c98f061b0dd00f998567a231bec0f9c0baef7db0613d0113938c99ba1c641a793f7a9f2f21a4f816004d1fba22a80f8
7
+ data.tar.gz: e139007a6c0c3b32e5617ca3d610297b76aff2db62a7a88e387e8c95a113c33c7a39024af770079cafd4c6489959ad7334434920b5d1bbed8ab7880c8c5a0225
@@ -0,0 +1 @@
1
+ strategy: 'bundler'
@@ -1,8 +1,17 @@
1
1
  rvm:
2
- - 1.9.3
3
- - 2.0.0
2
+ - 2.1.8
3
+ - 2.2.4
4
+ - 2.3.0
5
+ - ruby-head
4
6
  install: bundle install
7
+ before_install: gem install bundler -v 1.11.2
5
8
  script: bundle exec rake spec
6
9
  gemfile:
7
- - gemfiles/3.2.gemfile
8
- - gemfiles/4.0.gemfile
10
+ - gemfiles/4.1.gemfile
11
+ - gemfiles/4.2.gemfile
12
+ - gemfiles/5.0.gemfile
13
+ matrix:
14
+ allow_failures:
15
+ - gemfile: gemfiles/5.0.gemfile
16
+ - rvm: ruby-head
17
+ fast_finish: true
data/Appraisals CHANGED
@@ -1,9 +1,15 @@
1
- appraise "3.2" do
2
- gem "activerecord", "~> 3.2.15"
3
- gem "activerecord-mysql-index-hint", :path => "../"
1
+ appraise "4.1" do
2
+ gem "mysql2", "~> 0.3.13"
3
+ gem "activerecord", "~> 4.1.15"
4
+ gem "activerecord-mysql-index-hint", :path => "."
4
5
  end
5
6
 
6
- appraise "4.0" do
7
- gem "activerecord", "~> 4.0.0"
8
- gem "activerecord-mysql-index-hint", :path => "../"
7
+ appraise "4.2" do
8
+ gem "activerecord", "~> 4.2.6"
9
+ gem "activerecord-mysql-index-hint", :path => "."
10
+ end
11
+
12
+ appraise "5.0" do
13
+ gem "activerecord", "~> 5.0.0.beta3"
14
+ gem "activerecord-mysql-index-hint", :path => "."
9
15
  end
@@ -1,4 +1,7 @@
1
1
  # ChangeLog
2
+ ## 0.0.3
3
+ - Fix count with eager_load (Thanks @kamipo)
4
+
2
5
  ## 0.0.2
3
6
  - Don't directly touch AR::Base, but do it via AS.on_load (Thanks @amatsuda)
4
7
 
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'rake'
23
23
  spec.add_development_dependency 'appraisal'
24
24
  spec.add_development_dependency 'rspec'
25
- spec.add_development_dependency 'mysql2'
25
+ spec.add_development_dependency 'mysql2', '>= 0.3.18', '< 0.5'
26
26
  end
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "mysql2", "~> 0.3.13"
6
+ gem "activerecord", "~> 4.1.15"
7
+ gem "activerecord-mysql-index-hint", :path => "../"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 4.2.6"
6
+ gem "activerecord-mysql-index-hint", :path => "../"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.0.0.beta3"
6
+ gem "activerecord-mysql-index-hint", :path => "../"
7
+
8
+ gemspec :path => "../"
@@ -17,7 +17,7 @@ module ActiveRecordMysqlIndexHint
17
17
  def from_with_index_hint(hint_type, *args)
18
18
  return self if args.blank?
19
19
  indexes = args.map {|index| connection.quote_column_name index }
20
- self.from("#{quoted_table_name} #{hint_type} INDEX(#{indexes.join(', ')})")
20
+ self.from([Arel.sql("#{quoted_table_name} #{hint_type} INDEX(#{indexes.join(', ')})")])
21
21
  end
22
22
  end
23
23
 
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordMysqlIndexHint
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,21 +1,30 @@
1
1
  require 'active_record'
2
- require 'mysql2'
3
2
  require 'active_record/connection_adapters/mysql2_adapter'
4
3
  require 'activerecord-mysql-index-hint'
5
4
 
6
- module Mysql2
7
- class Client
8
- def initialize(opts={})
9
- @query_options = @@default_query_options.dup.merge opts
10
- end
5
+ module ActiveRecord
6
+ module ConnectionHandling
7
+ prepend Module.new {
8
+ def mysql2_connection(config)
9
+ ConnectionAdapters::Mysql2Adapter.new(nil, logger, nil, config)
10
+ end
11
+ }
11
12
  end
12
- end
13
13
 
14
- ActiveRecord::ConnectionAdapters::Mysql2Adapter.class_eval do
15
- def quote_string(string)
16
- string
17
- end
18
- def configure_connection
14
+ module ConnectionAdapters
15
+ class Mysql2Adapter
16
+ prepend Module.new {
17
+ def quote_string(string)
18
+ string
19
+ end
20
+
21
+ def reconnect!
22
+ end
23
+
24
+ def configure_connection
25
+ end
26
+ }
27
+ end
19
28
  end
20
29
  end
21
30
 
@@ -29,40 +38,44 @@ class Product < ActiveRecord::Base
29
38
  establish_connection 'mysql2://user@host/db'
30
39
  end
31
40
 
41
+ def normalize_spaces(sql)
42
+ sql.gsub(/ {2,}/, ' ')
43
+ end
44
+
32
45
  describe 'ActiveRecord Index Hint' do
33
46
  context 'with AR::Relation' do
34
47
  it do
35
48
  expect(
36
- Product.limit(1).use_index(:idx1).to_sql
37
- ).to eq('SELECT `products`.* FROM `products` USE INDEX(`idx1`) LIMIT 1')
49
+ normalize_spaces Product.limit(1).use_index(:idx1).to_sql
50
+ ).to eq('SELECT `products`.* FROM `products` USE INDEX(`idx1`) LIMIT 1')
38
51
  end
39
52
 
40
53
  it do
41
54
  expect(
42
- Product.limit(1).force_index(:idx1).to_sql
43
- ).to eq('SELECT `products`.* FROM `products` FORCE INDEX(`idx1`) LIMIT 1')
55
+ normalize_spaces Product.limit(1).force_index(:idx1).to_sql
56
+ ).to eq('SELECT `products`.* FROM `products` FORCE INDEX(`idx1`) LIMIT 1')
44
57
  end
45
58
 
46
59
  it do
47
60
  expect(
48
- Product.limit(1).ignore_index(:idx1).to_sql
49
- ).to eq('SELECT `products`.* FROM `products` IGNORE INDEX(`idx1`) LIMIT 1')
61
+ normalize_spaces Product.limit(1).ignore_index(:idx1).to_sql
62
+ ).to eq('SELECT `products`.* FROM `products` IGNORE INDEX(`idx1`) LIMIT 1')
50
63
  end
51
64
  end
52
65
 
53
66
  context 'with AR::Base' do
54
67
  it do
55
68
  expect(
56
- Product.use_index(:idx1).limit(1).to_sql
57
- ).to eq('SELECT `products`.* FROM `products` USE INDEX(`idx1`) LIMIT 1')
69
+ normalize_spaces Product.use_index(:idx1).limit(1).to_sql
70
+ ).to eq('SELECT `products`.* FROM `products` USE INDEX(`idx1`) LIMIT 1')
58
71
  end
59
72
  end
60
73
 
61
74
  context 'with multiple indexes' do
62
75
  it do
63
76
  expect(
64
- Product.limit(1).use_index(:idx1, :idx2).to_sql
65
- ).to eq('SELECT `products`.* FROM `products` USE INDEX(`idx1`, `idx2`) LIMIT 1')
77
+ normalize_spaces Product.limit(1).use_index(:idx1, :idx2).to_sql
78
+ ).to eq('SELECT `products`.* FROM `products` USE INDEX(`idx1`, `idx2`) LIMIT 1')
66
79
  end
67
80
  end
68
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysql-index-hint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Issei Naruta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-28 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -86,14 +86,20 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.3.18
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.5'
90
93
  type: :development
91
94
  prerelease: false
92
95
  version_requirements: !ruby/object:Gem::Requirement
93
96
  requirements:
94
97
  - - ">="
95
98
  - !ruby/object:Gem::Version
96
- version: '0'
99
+ version: 0.3.18
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.5'
97
103
  description: MySQL index hint support for ActiveRecord
98
104
  email:
99
105
  - naruta@cookpad.com
@@ -103,6 +109,7 @@ extra_rdoc_files: []
103
109
  files:
104
110
  - ".gitignore"
105
111
  - ".rspec"
112
+ - ".tachikoma.yml"
106
113
  - ".travis.yml"
107
114
  - Appraisals
108
115
  - ChangeLog.md
@@ -111,8 +118,9 @@ files:
111
118
  - README.md
112
119
  - Rakefile
113
120
  - activerecord-mysql-index-hint.gemspec
114
- - gemfiles/3.2.gemfile
115
- - gemfiles/4.0.gemfile
121
+ - gemfiles/4.1.gemfile
122
+ - gemfiles/4.2.gemfile
123
+ - gemfiles/5.0.gemfile
116
124
  - lib/activerecord-mysql-index-hint.rb
117
125
  - lib/activerecord-mysql-index-hint/version.rb
118
126
  - spec/activerecord-mysql-index-hint_spec.rb
@@ -137,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
145
  version: '0'
138
146
  requirements: []
139
147
  rubyforge_project:
140
- rubygems_version: 2.2.2
148
+ rubygems_version: 2.5.1
141
149
  signing_key:
142
150
  specification_version: 4
143
151
  summary: MySQL index hint support for ActiveRecord
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 3.2.15"
6
- gem "activerecord-mysql-index-hint", :path=>"../"
7
-
8
- gemspec :path=>"../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.0.0"
6
- gem "activerecord-mysql-index-hint", :path=>"../"
7
-
8
- gemspec :path=>"../"