arel-mysql-index-hint 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Appraisals +4 -0
- data/arel-mysql-index-hint.gemspec +7 -3
- data/gemfiles/activerecord_4.0.gemfile +7 -0
- data/lib/arel-mysql-index-hint.rb +1 -0
- data/lib/arel-mysql-index-hint/version.rb +3 -0
- data/spec/arel-mysql-index-hint/eager_load_spec.rb +45 -43
- data/spec/arel-mysql-index-hint/includes_spec.rb +45 -43
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 056f6a03232b9aa1c28dec24244582dd10b29c79
|
4
|
+
data.tar.gz: 5a84926f236b5fd5b07f968ba06390dc648eeef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3126292446906c1aa96989d9fce221bfbca9b7d1019ddc4b3b269555ead1a247a4125bd86c5e9f3a1e05d520257177dd51c87f77a4fbc8bb74ad94e737f20eae
|
7
|
+
data.tar.gz: e4847360b6926b8a151dc29adbbc6ea4aada8113031bde8a6befa3188958fa52ddd106148b4bc078a0bfbfa612985304162307fae815dbe7f9bcbd27ffe2acd2
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'arel-mysql-index-hint/version'
|
5
|
+
|
2
6
|
Gem::Specification.new do |spec|
|
3
7
|
spec.name = "arel-mysql-index-hint"
|
4
|
-
spec.version =
|
8
|
+
spec.version = ArelMysqlIndexHint::VERSION
|
5
9
|
spec.authors = ["Genki Sugawara"]
|
6
10
|
spec.email = ["sgwr_dts@yahoo.co.jp"]
|
7
11
|
spec.summary = %q{Add index hint to MySQL query in Arel.}
|
@@ -14,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
14
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
19
|
spec.require_paths = ["lib"]
|
16
20
|
|
17
|
-
spec.add_dependency "activerecord", ">= 4.
|
18
|
-
spec.add_dependency "arel", ">=
|
21
|
+
spec.add_dependency "activerecord", ">= 4.0.0"
|
22
|
+
spec.add_dependency "arel", ">= 4.0.0"
|
19
23
|
|
20
24
|
spec.add_development_dependency "bundler"
|
21
25
|
spec.add_development_dependency "rake"
|
@@ -1,53 +1,55 @@
|
|
1
|
-
|
2
|
-
describe "
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
let(:sql) do
|
13
|
-
"SELECT `users`.`id` AS t0_r0, `users`.`name` AS t0_r1, `users`.`email` AS t0_r2, `users`.`created_at` AS t0_r3, `users`.`updated_at` AS t0_r4, `users`.`password_digest` AS t0_r5, `users`.`remember_token` AS t0_r6, `users`.`admin` AS t0_r7, `microposts`.`id` AS t1_r0, `microposts`.`content` AS t1_r1, `microposts`.`user_id` AS t1_r2, `microposts`.`created_at` AS t1_r3, `microposts`.`updated_at` AS t1_r4 " +
|
14
|
-
"FROM `users` " +
|
15
|
-
"LEFT OUTER JOIN `microposts` " +
|
16
|
-
"#{hint_type.to_s.upcase} INDEX (`index_microposts_on_user_id_and_created_at`) " +
|
17
|
-
"ON `microposts`.`user_id` = `users`.`id` " +
|
18
|
-
"WHERE `microposts`.`id` = 1"
|
19
|
-
end
|
1
|
+
if ActiveRecord::VERSION::MINOR >= 1
|
2
|
+
describe "arel-mysql-index-hint" do
|
3
|
+
describe "#eager_load" do
|
4
|
+
context "when single index" do
|
5
|
+
subject do
|
6
|
+
User.
|
7
|
+
eager_load(:microposts).
|
8
|
+
where(microposts: {id: 1}).
|
9
|
+
hint(microposts: {index_microposts_on_user_id_and_created_at: hint_type}).
|
10
|
+
to_sql.gsub(/\s+/, " ")
|
11
|
+
end
|
20
12
|
|
21
|
-
|
13
|
+
let(:sql) do
|
14
|
+
"SELECT `users`.`id` AS t0_r0, `users`.`name` AS t0_r1, `users`.`email` AS t0_r2, `users`.`created_at` AS t0_r3, `users`.`updated_at` AS t0_r4, `users`.`password_digest` AS t0_r5, `users`.`remember_token` AS t0_r6, `users`.`admin` AS t0_r7, `microposts`.`id` AS t1_r0, `microposts`.`content` AS t1_r1, `microposts`.`user_id` AS t1_r2, `microposts`.`created_at` AS t1_r3, `microposts`.`updated_at` AS t1_r4 " +
|
15
|
+
"FROM `users` " +
|
16
|
+
"LEFT OUTER JOIN `microposts` " +
|
17
|
+
"#{hint_type.to_s.upcase} INDEX (`index_microposts_on_user_id_and_created_at`) " +
|
18
|
+
"ON `microposts`.`user_id` = `users`.`id` " +
|
19
|
+
"WHERE `microposts`.`id` = 1"
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
end
|
22
|
+
let(:hint_type) { :force }
|
25
23
|
|
26
|
-
|
27
|
-
subject do
|
28
|
-
User.
|
29
|
-
eager_load(:microposts).
|
30
|
-
where(microposts: {id: 1}).
|
31
|
-
hint(
|
32
|
-
users: {index_users_on_email: hint_type},
|
33
|
-
microposts: {index_microposts_on_user_id_and_created_at: hint_type},
|
34
|
-
).
|
35
|
-
to_sql.gsub(/\s+/, " ")
|
24
|
+
it { is_expected.to eq sql }
|
36
25
|
end
|
37
26
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
27
|
+
context "when multiple indexes" do
|
28
|
+
subject do
|
29
|
+
User.
|
30
|
+
eager_load(:microposts).
|
31
|
+
where(microposts: {id: 1}).
|
32
|
+
hint(
|
33
|
+
users: {index_users_on_email: hint_type},
|
34
|
+
microposts: {index_microposts_on_user_id_and_created_at: hint_type},
|
35
|
+
).
|
36
|
+
to_sql.gsub(/\s+/, " ")
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:sql) do
|
40
|
+
"SELECT `users`.`id` AS t0_r0, `users`.`name` AS t0_r1, `users`.`email` AS t0_r2, `users`.`created_at` AS t0_r3, `users`.`updated_at` AS t0_r4, `users`.`password_digest` AS t0_r5, `users`.`remember_token` AS t0_r6, `users`.`admin` AS t0_r7, `microposts`.`id` AS t1_r0, `microposts`.`content` AS t1_r1, `microposts`.`user_id` AS t1_r2, `microposts`.`created_at` AS t1_r3, `microposts`.`updated_at` AS t1_r4 " +
|
41
|
+
"FROM `users` " +
|
42
|
+
"#{hint_type.to_s.upcase} INDEX (`index_users_on_email`) " +
|
43
|
+
"LEFT OUTER JOIN `microposts` " +
|
44
|
+
"#{hint_type.to_s.upcase} INDEX (`index_microposts_on_user_id_and_created_at`) " +
|
45
|
+
"ON `microposts`.`user_id` = `users`.`id` " +
|
46
|
+
"WHERE `microposts`.`id` = 1"
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
+
let(:hint_type) { :force }
|
49
50
|
|
50
|
-
|
51
|
+
it { is_expected.to eq sql }
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -1,53 +1,55 @@
|
|
1
|
-
|
2
|
-
describe "
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
let(:sql) do
|
13
|
-
"SELECT `users`.`id` AS t0_r0, `users`.`name` AS t0_r1, `users`.`email` AS t0_r2, `users`.`created_at` AS t0_r3, `users`.`updated_at` AS t0_r4, `users`.`password_digest` AS t0_r5, `users`.`remember_token` AS t0_r6, `users`.`admin` AS t0_r7, `microposts`.`id` AS t1_r0, `microposts`.`content` AS t1_r1, `microposts`.`user_id` AS t1_r2, `microposts`.`created_at` AS t1_r3, `microposts`.`updated_at` AS t1_r4 " +
|
14
|
-
"FROM `users` " +
|
15
|
-
"LEFT OUTER JOIN `microposts` " +
|
16
|
-
"#{hint_type.to_s.upcase} INDEX (`index_microposts_on_user_id_and_created_at`) " +
|
17
|
-
"ON `microposts`.`user_id` = `users`.`id` " +
|
18
|
-
"WHERE `microposts`.`id` = 1"
|
19
|
-
end
|
1
|
+
if ActiveRecord::VERSION::MINOR >= 1
|
2
|
+
describe "arel-mysql-index-hint" do
|
3
|
+
describe "#includes" do
|
4
|
+
context "when single index" do
|
5
|
+
subject do
|
6
|
+
User.
|
7
|
+
includes(:microposts).
|
8
|
+
where(microposts: {id: 1}).
|
9
|
+
hint(microposts: {index_microposts_on_user_id_and_created_at: hint_type}).
|
10
|
+
to_sql.gsub(/\s+/, " ")
|
11
|
+
end
|
20
12
|
|
21
|
-
|
13
|
+
let(:sql) do
|
14
|
+
"SELECT `users`.`id` AS t0_r0, `users`.`name` AS t0_r1, `users`.`email` AS t0_r2, `users`.`created_at` AS t0_r3, `users`.`updated_at` AS t0_r4, `users`.`password_digest` AS t0_r5, `users`.`remember_token` AS t0_r6, `users`.`admin` AS t0_r7, `microposts`.`id` AS t1_r0, `microposts`.`content` AS t1_r1, `microposts`.`user_id` AS t1_r2, `microposts`.`created_at` AS t1_r3, `microposts`.`updated_at` AS t1_r4 " +
|
15
|
+
"FROM `users` " +
|
16
|
+
"LEFT OUTER JOIN `microposts` " +
|
17
|
+
"#{hint_type.to_s.upcase} INDEX (`index_microposts_on_user_id_and_created_at`) " +
|
18
|
+
"ON `microposts`.`user_id` = `users`.`id` " +
|
19
|
+
"WHERE `microposts`.`id` = 1"
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
end
|
22
|
+
let(:hint_type) { :force }
|
25
23
|
|
26
|
-
|
27
|
-
subject do
|
28
|
-
User.
|
29
|
-
includes(:microposts).
|
30
|
-
where(microposts: {id: 1}).
|
31
|
-
hint(
|
32
|
-
users: {index_users_on_email: hint_type},
|
33
|
-
microposts: {index_microposts_on_user_id_and_created_at: hint_type},
|
34
|
-
).
|
35
|
-
to_sql.gsub(/\s+/, " ")
|
24
|
+
it { is_expected.to eq sql }
|
36
25
|
end
|
37
26
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
27
|
+
context "when multiple indexes" do
|
28
|
+
subject do
|
29
|
+
User.
|
30
|
+
includes(:microposts).
|
31
|
+
where(microposts: {id: 1}).
|
32
|
+
hint(
|
33
|
+
users: {index_users_on_email: hint_type},
|
34
|
+
microposts: {index_microposts_on_user_id_and_created_at: hint_type},
|
35
|
+
).
|
36
|
+
to_sql.gsub(/\s+/, " ")
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:sql) do
|
40
|
+
"SELECT `users`.`id` AS t0_r0, `users`.`name` AS t0_r1, `users`.`email` AS t0_r2, `users`.`created_at` AS t0_r3, `users`.`updated_at` AS t0_r4, `users`.`password_digest` AS t0_r5, `users`.`remember_token` AS t0_r6, `users`.`admin` AS t0_r7, `microposts`.`id` AS t1_r0, `microposts`.`content` AS t1_r1, `microposts`.`user_id` AS t1_r2, `microposts`.`created_at` AS t1_r3, `microposts`.`updated_at` AS t1_r4 " +
|
41
|
+
"FROM `users` " +
|
42
|
+
"#{hint_type.to_s.upcase} INDEX (`index_users_on_email`) " +
|
43
|
+
"LEFT OUTER JOIN `microposts` " +
|
44
|
+
"#{hint_type.to_s.upcase} INDEX (`index_microposts_on_user_id_and_created_at`) " +
|
45
|
+
"ON `microposts`.`user_id` = `users`.`id` " +
|
46
|
+
"WHERE `microposts`.`id` = 1"
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
+
let(:hint_type) { :force }
|
49
50
|
|
50
|
-
|
51
|
+
it { is_expected.to eq sql }
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel-mysql-index-hint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: 4.0.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: 4.
|
26
|
+
version: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: arel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 4.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,12 +153,14 @@ files:
|
|
153
153
|
- Rakefile
|
154
154
|
- Schemafile
|
155
155
|
- arel-mysql-index-hint.gemspec
|
156
|
+
- gemfiles/activerecord_4.0.gemfile
|
156
157
|
- gemfiles/activerecord_4.1.gemfile
|
157
158
|
- gemfiles/activerecord_4.2.gemfile
|
158
159
|
- lib/arel-mysql-index-hint.rb
|
159
160
|
- lib/arel-mysql-index-hint/active_record-hint_methods.rb
|
160
161
|
- lib/arel-mysql-index-hint/arel-table.rb
|
161
162
|
- lib/arel-mysql-index-hint/arel-visitors-mysql.rb
|
163
|
+
- lib/arel-mysql-index-hint/version.rb
|
162
164
|
- spec/arel-mysql-index-hint/eager_load_spec.rb
|
163
165
|
- spec/arel-mysql-index-hint/includes_spec.rb
|
164
166
|
- spec/arel-mysql-index-hint/joins_spec.rb
|