activerecord-mysql-index-hint 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tachikoma.yml +1 -0
- data/.travis.yml +13 -4
- data/Appraisals +12 -6
- data/ChangeLog.md +3 -0
- data/activerecord-mysql-index-hint.gemspec +1 -1
- data/gemfiles/4.1.gemfile +9 -0
- data/gemfiles/4.2.gemfile +8 -0
- data/gemfiles/5.0.gemfile +8 -0
- data/lib/activerecord-mysql-index-hint.rb +1 -1
- data/lib/activerecord-mysql-index-hint/version.rb +1 -1
- data/spec/activerecord-mysql-index-hint_spec.rb +35 -22
- metadata +15 -7
- data/gemfiles/3.2.gemfile +0 -8
- data/gemfiles/4.0.gemfile +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7191260fbe07cc9cb7cfcfb9b83b984e2b28ccd
|
4
|
+
data.tar.gz: 05eaa9aa8ddc2190ce7d408af6a4ee1bf562dd34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 576b2f9b945d6fc3f43becf70b69847d6c98f061b0dd00f998567a231bec0f9c0baef7db0613d0113938c99ba1c641a793f7a9f2f21a4f816004d1fba22a80f8
|
7
|
+
data.tar.gz: e139007a6c0c3b32e5617ca3d610297b76aff2db62a7a88e387e8c95a113c33c7a39024af770079cafd4c6489959ad7334434920b5d1bbed8ab7880c8c5a0225
|
data/.tachikoma.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
strategy: 'bundler'
|
data/.travis.yml
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
rvm:
|
2
|
-
- 1.
|
3
|
-
- 2.
|
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/
|
8
|
-
- gemfiles/4.
|
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 "
|
2
|
-
gem "
|
3
|
-
gem "activerecord
|
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.
|
7
|
-
gem "activerecord", "~> 4.
|
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
|
data/ChangeLog.md
CHANGED
@@ -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
|
@@ -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,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
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
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
|
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
|
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
|
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
|
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.
|
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:
|
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:
|
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:
|
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/
|
115
|
-
- gemfiles/4.
|
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.
|
148
|
+
rubygems_version: 2.5.1
|
141
149
|
signing_key:
|
142
150
|
specification_version: 4
|
143
151
|
summary: MySQL index hint support for ActiveRecord
|
data/gemfiles/3.2.gemfile
DELETED