extended_joins_impl 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 +4 -4
- data/lib/extended_joins_impl/version.rb +1 -1
- data/lib/extended_joins_impl.rb +4 -2
- data/spec/extended_joins_impl_spec.rb +27 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dce719cbfac8324b50d1cfb1b6435cdcc6b9743
|
4
|
+
data.tar.gz: 8dc129e90dd5c86ea54535532208e6c9ebbd2180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14c06ab1463e761a0aa2c828ba40428e480e10a21a7ecb089f6348fee60076a17b1945c08d203e35abb7e03a811636fb416304004127043da46500d954b9157b
|
7
|
+
data.tar.gz: c621f70223f86459eb38bf0ec77ba26e027f04d947aa6f85c8cdeb2389765ab3a4892e7d6281eaa698d6db27b46bcfa1e28770e262d7564f3a68ba2f68dea584
|
data/lib/extended_joins_impl.rb
CHANGED
@@ -5,39 +5,55 @@ require 'extended_joins_impl'
|
|
5
5
|
describe ExtendedJoinsImpl do
|
6
6
|
|
7
7
|
it "inner join" do
|
8
|
-
sql =
|
8
|
+
sql = if ActiveRecord::VERSION::MAJOR >= 4
|
9
|
+
User.extended_joins(:inner, Type.all).to_sql
|
10
|
+
else
|
11
|
+
User.extended_joins(:inner, Type.scoped).to_sql
|
12
|
+
end
|
9
13
|
expect(sql).to include "INNER JOIN"
|
10
14
|
expect(sql).to include "\"users\".\"type_id\" = types.\"id\""
|
11
15
|
end
|
12
16
|
|
13
17
|
it "left outer join" do
|
14
|
-
sql =
|
18
|
+
sql = if ActiveRecord::VERSION::MAJOR >= 4
|
19
|
+
User.extended_joins(:outer, Type.all).to_sql
|
20
|
+
else
|
21
|
+
User.extended_joins(:outer, Type.scoped).to_sql
|
22
|
+
end
|
15
23
|
expect(sql).to include "LEFT OUTER JOIN"
|
16
24
|
expect(sql).to include "\"users\".\"type_id\" = types.\"id\""
|
17
25
|
end
|
18
26
|
|
19
27
|
it "subquery join" do
|
20
|
-
sql = User.
|
28
|
+
sql = User.extended_joins(:outer, Type.where(id: 3)).to_sql
|
21
29
|
expect(sql).to include "LEFT OUTER JOIN"
|
22
30
|
expect(sql).to include "\"users\".\"type_id\" = types.\"id\""
|
23
31
|
expect(sql).to include "WHERE \"types\".\"id\" = 3"
|
24
32
|
end
|
25
33
|
|
26
34
|
it "join alias" do
|
27
|
-
sql = User.
|
35
|
+
sql = User.extended_joins(:outer, Type.where(id: 3), as: "user_types").to_sql
|
28
36
|
expect(sql).to include "LEFT OUTER JOIN"
|
29
37
|
expect(sql).to include "\"users\".\"type_id\" = user_types.\"id\""
|
30
38
|
expect(sql).to include "WHERE \"types\".\"id\" = 3"
|
31
39
|
end
|
32
40
|
|
33
41
|
it "join on condition" do
|
34
|
-
sql =
|
42
|
+
sql = if ActiveRecord::VERSION::MAJOR >= 4
|
43
|
+
User.extended_joins(:inner, Note.all, on: {code: :user_code}).to_sql
|
44
|
+
else
|
45
|
+
User.extended_joins(:inner, Note.scoped, on: {code: :user_code}).to_sql
|
46
|
+
end
|
35
47
|
expect(sql).to include "INNER JOIN"
|
36
48
|
expect(sql).to include "\"users\".\"code\" = notes.\"user_code\""
|
37
49
|
end
|
38
50
|
|
39
51
|
it "join on constant" do
|
40
|
-
sql =
|
52
|
+
sql = if ActiveRecord::VERSION::MAJOR >= 4
|
53
|
+
User.extended_joins(:inner, Note.all, where: {id: 3, user_code: 4}).to_sql
|
54
|
+
else
|
55
|
+
User.extended_joins(:inner, Note.scoped, where: {id: 3, user_code: 4}).to_sql
|
56
|
+
end
|
41
57
|
expect(sql).to include "INNER JOIN"
|
42
58
|
expect(sql).to include "\"users\".\"id\" = notes.\"user_id\""
|
43
59
|
expect(sql).to include "notes.\"id\" = 3"
|
@@ -45,7 +61,11 @@ describe ExtendedJoinsImpl do
|
|
45
61
|
end
|
46
62
|
|
47
63
|
it "join with association" do
|
48
|
-
sql =
|
64
|
+
sql = if ActiveRecord::VERSION::MAJOR >= 4
|
65
|
+
User.extended_joins(:inner, Note.all, as: "user_notes").to_sql
|
66
|
+
else
|
67
|
+
User.extended_joins(:inner, Note.scoped, as: "user_notes").to_sql
|
68
|
+
end
|
49
69
|
expect(sql).to include "INNER JOIN"
|
50
70
|
expect(sql).to include "\"users\".\"code\" = user_notes.\"user_code\""
|
51
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extended_joins_impl
|
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
|
- MnrUchida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|