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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e433fd8290f9349c0e86772ece267aa611800ccc
4
- data.tar.gz: a83ef70e8c11b80ce7abc94167ac69dbc9fcfa12
3
+ metadata.gz: 056f6a03232b9aa1c28dec24244582dd10b29c79
4
+ data.tar.gz: 5a84926f236b5fd5b07f968ba06390dc648eeef6
5
5
  SHA512:
6
- metadata.gz: 2a380d743800bbf28a6046d3e1c30b83100c279ce2d2b98dcf928ac1886db880b403703951aff81becea95cdfa8c4bfb3937f9b12c1a5d7afaee48ef49e8de64
7
- data.tar.gz: 68fa23137460618b48075bb2056ec01bea2c28da9408512c8e2f0ccc45bb649f2954a3ce0a28cf1367c74cb05a07e4d74f80e88b7696c15fa70f684a08aabc1f
6
+ metadata.gz: 3126292446906c1aa96989d9fce221bfbca9b7d1019ddc4b3b269555ead1a247a4125bd86c5e9f3a1e05d520257177dd51c87f77a4fbc8bb74ad94e737f20eae
7
+ data.tar.gz: e4847360b6926b8a151dc29adbbc6ea4aada8113031bde8a6befa3188958fa52ddd106148b4bc078a0bfbfa612985304162307fae815dbe7f9bcbd27ffe2acd2
data/.travis.yml CHANGED
@@ -7,5 +7,6 @@ script:
7
7
  - bundle install
8
8
  - bundle exec rake
9
9
  gemfile:
10
+ - gemfiles/activerecord_4.0.gemfile
10
11
  - gemfiles/activerecord_4.1.gemfile
11
12
  - gemfiles/activerecord_4.2.gemfile
data/Appraisals CHANGED
@@ -1,3 +1,7 @@
1
+ appraise "activerecord-4.0" do
2
+ gem "activerecord", "4.0.13"
3
+ end
4
+
1
5
  appraise "activerecord-4.1" do
2
6
  gem "activerecord", "4.1.10"
3
7
  end
@@ -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 = "0.1.3"
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.1.0"
18
- spec.add_dependency "arel", ">= 5.0.0"
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"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "4.0.13"
6
+
7
+ gemspec :path => "../"
@@ -1,4 +1,5 @@
1
1
  require "active_support"
2
+ require "arel-mysql-index-hint/version"
2
3
 
3
4
  ActiveSupport.on_load :active_record do
4
5
  require "arel-mysql-index-hint/active_record-hint_methods"
@@ -0,0 +1,3 @@
1
+ module ArelMysqlIndexHint
2
+ VERSION = '0.1.4'
3
+ end
@@ -1,53 +1,55 @@
1
- describe "arel-mysql-index-hint" do
2
- describe "#eager_load" do
3
- context "when single index" do
4
- subject do
5
- User.
6
- eager_load(:microposts).
7
- where(microposts: {id: 1}).
8
- hint(microposts: {index_microposts_on_user_id_and_created_at: hint_type}).
9
- to_sql.gsub(/\s+/, " ")
10
- end
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
- let(:hint_type) { :force }
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
- it { is_expected.to eq sql }
24
- end
22
+ let(:hint_type) { :force }
25
23
 
26
- context "when multiple indexes" do
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
- let(:sql) do
39
- "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 " +
40
- "FROM `users` " +
41
- "#{hint_type.to_s.upcase} INDEX (`index_users_on_email`) " +
42
- "LEFT OUTER JOIN `microposts` " +
43
- "#{hint_type.to_s.upcase} INDEX (`index_microposts_on_user_id_and_created_at`) " +
44
- "ON `microposts`.`user_id` = `users`.`id` " +
45
- "WHERE `microposts`.`id` = 1"
46
- end
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
- let(:hint_type) { :force }
49
+ let(:hint_type) { :force }
49
50
 
50
- it { is_expected.to eq sql }
51
+ it { is_expected.to eq sql }
52
+ end
51
53
  end
52
54
  end
53
55
  end
@@ -1,53 +1,55 @@
1
- describe "arel-mysql-index-hint" do
2
- describe "#includes" do
3
- context "when single index" do
4
- subject do
5
- User.
6
- includes(:microposts).
7
- where(microposts: {id: 1}).
8
- hint(microposts: {index_microposts_on_user_id_and_created_at: hint_type}).
9
- to_sql.gsub(/\s+/, " ")
10
- end
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
- let(:hint_type) { :force }
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
- it { is_expected.to eq sql }
24
- end
22
+ let(:hint_type) { :force }
25
23
 
26
- context "when multiple indexes" do
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
- let(:sql) do
39
- "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 " +
40
- "FROM `users` " +
41
- "#{hint_type.to_s.upcase} INDEX (`index_users_on_email`) " +
42
- "LEFT OUTER JOIN `microposts` " +
43
- "#{hint_type.to_s.upcase} INDEX (`index_microposts_on_user_id_and_created_at`) " +
44
- "ON `microposts`.`user_id` = `users`.`id` " +
45
- "WHERE `microposts`.`id` = 1"
46
- end
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
- let(:hint_type) { :force }
49
+ let(:hint_type) { :force }
49
50
 
50
- it { is_expected.to eq sql }
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.3
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.1.0
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.1.0
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: 5.0.0
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: 5.0.0
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