arel 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/README.markdown +0 -2
- data/Rakefile +2 -2
- data/arel.gemspec +13 -3
- data/lib/arel.rb +2 -2
- data/lib/arel/algebra/relations/relation.rb +3 -2
- data/lib/arel/engines/sql/compilers/ibm_db_compiler.rb +62 -0
- data/lib/arel/engines/sql/compilers/mysql_compiler.rb +11 -0
- data/lib/arel/engines/sql/compilers/oracle_compiler.rb +95 -0
- data/lib/arel/engines/sql/compilers/postgresql_compiler.rb +42 -0
- data/lib/arel/engines/sql/compilers/sqlite_compiler.rb +9 -0
- data/lib/arel/engines/sql/engine.rb +17 -3
- data/lib/arel/engines/sql/formatters.rb +3 -3
- data/lib/arel/engines/sql/relations.rb +1 -0
- data/lib/arel/engines/sql/relations/compiler.rb +118 -0
- data/lib/arel/engines/sql/relations/relation.rb +38 -63
- data/lib/arel/engines/sql/relations/table.rb +23 -3
- data/lib/arel/engines/sql/relations/utilities/externalization.rb +1 -1
- data/lib/arel/engines/sql/relations/writes.rb +4 -71
- data/spec/arel/algebra/unit/relations/relation_spec.rb +1 -2
- data/spec/arel/algebra/unit/relations/table_spec.rb +0 -1
- data/spec/arel/engines/memory/integration/joins/cross_engine_spec.rb +9 -4
- data/spec/arel/engines/sql/integration/joins/with_adjacency_spec.rb +68 -19
- data/spec/arel/engines/sql/integration/joins/with_aggregations_spec.rb +74 -20
- data/spec/arel/engines/sql/integration/joins/with_compounds_spec.rb +33 -3
- data/spec/arel/engines/sql/unit/predicates/binary_spec.rb +22 -2
- data/spec/arel/engines/sql/unit/predicates/equality_spec.rb +15 -3
- data/spec/arel/engines/sql/unit/predicates/in_spec.rb +59 -5
- data/spec/arel/engines/sql/unit/predicates/predicates_spec.rb +12 -0
- data/spec/arel/engines/sql/unit/primitives/attribute_spec.rb +24 -1
- data/spec/arel/engines/sql/unit/primitives/expression_spec.rb +5 -1
- data/spec/arel/engines/sql/unit/primitives/literal_spec.rb +10 -2
- data/spec/arel/engines/sql/unit/relations/alias_spec.rb +11 -1
- data/spec/arel/engines/sql/unit/relations/delete_spec.rb +23 -3
- data/spec/arel/engines/sql/unit/relations/from_spec.rb +16 -2
- data/spec/arel/engines/sql/unit/relations/group_spec.rb +18 -2
- data/spec/arel/engines/sql/unit/relations/having_spec.rb +12 -3
- data/spec/arel/engines/sql/unit/relations/insert_spec.rb +37 -1
- data/spec/arel/engines/sql/unit/relations/join_spec.rb +53 -11
- data/spec/arel/engines/sql/unit/relations/lock_spec.rb +25 -0
- data/spec/arel/engines/sql/unit/relations/order_spec.rb +52 -4
- data/spec/arel/engines/sql/unit/relations/project_spec.rb +38 -5
- data/spec/arel/engines/sql/unit/relations/skip_spec.rb +10 -1
- data/spec/arel/engines/sql/unit/relations/table_spec.rb +26 -5
- data/spec/arel/engines/sql/unit/relations/take_spec.rb +18 -1
- data/spec/arel/engines/sql/unit/relations/update_spec.rb +47 -1
- data/spec/arel/engines/sql/unit/relations/where_spec.rb +18 -2
- data/spec/connections/oracle_connection.rb +19 -0
- data/spec/schemas/mysql_schema.rb +2 -1
- data/spec/schemas/oracle_schema.rb +20 -0
- data/spec/schemas/postgresql_schema.rb +2 -1
- data/spec/schemas/sqlite3_schema.rb +2 -1
- data/spec/spec_helper.rb +16 -7
- metadata +31 -9
@@ -22,7 +22,11 @@ module Arel
|
|
22
22
|
sql.should be_like(%Q{`users`.`id` IN (1, 2, 3)})
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
adapter_is :oracle do
|
26
|
+
sql.should be_like(%Q{"USERS"."ID" IN (1, 2, 3)})
|
27
|
+
end
|
28
|
+
|
29
|
+
adapter_is_not :mysql, :oracle do
|
26
30
|
sql.should be_like(%Q{"users"."id" IN (1, 2, 3)})
|
27
31
|
end
|
28
32
|
end
|
@@ -40,7 +44,11 @@ module Arel
|
|
40
44
|
sql.should be_like(%Q{`users`.`id` IN (1, 2, 3)})
|
41
45
|
end
|
42
46
|
|
43
|
-
|
47
|
+
adapter_is :oracle do
|
48
|
+
sql.should be_like(%Q{"USERS"."ID" IN (1, 2, 3)})
|
49
|
+
end
|
50
|
+
|
51
|
+
adapter_is_not :mysql, :oracle do
|
44
52
|
sql.should be_like(%Q{"users"."id" IN (1, 2, 3)})
|
45
53
|
end
|
46
54
|
end
|
@@ -58,7 +66,11 @@ module Arel
|
|
58
66
|
sql.should be_like(%Q{`users`.`id` IN (NULL)})
|
59
67
|
end
|
60
68
|
|
61
|
-
|
69
|
+
adapter_is :oracle do
|
70
|
+
sql.should be_like(%Q{"USERS"."ID" IN (NULL)})
|
71
|
+
end
|
72
|
+
|
73
|
+
adapter_is_not :mysql, :oracle do
|
62
74
|
sql.should be_like(%Q{"users"."id" IN (NULL)})
|
63
75
|
end
|
64
76
|
end
|
@@ -78,12 +90,48 @@ module Arel
|
|
78
90
|
sql.should be_like(%Q{`users`.`id` BETWEEN 1 AND 2})
|
79
91
|
end
|
80
92
|
|
81
|
-
|
93
|
+
adapter_is :oracle do
|
94
|
+
sql.should be_like(%Q{"USERS"."ID" BETWEEN 1 AND 2})
|
95
|
+
end
|
96
|
+
|
97
|
+
adapter_is_not :mysql, :oracle do
|
82
98
|
sql.should be_like(%Q{"users"."id" BETWEEN 1 AND 2})
|
83
99
|
end
|
84
100
|
end
|
85
101
|
end
|
86
102
|
|
103
|
+
describe 'when relating to a time range' do
|
104
|
+
before do
|
105
|
+
@relation = Arel::Table.new(:developers)
|
106
|
+
@attribute = @relation[:created_at]
|
107
|
+
@range = Time.mktime(2010, 01, 01)..Time.mktime(2010, 02, 01)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'manufactures sql with a between' do
|
111
|
+
sql = In.new(@attribute, @range).to_sql
|
112
|
+
|
113
|
+
adapter_is :mysql do
|
114
|
+
sql.should be_like(%Q{`developers`.`created_at` BETWEEN '2010-01-01 00:00:00' AND '2010-02-01 00:00:00'})
|
115
|
+
end
|
116
|
+
|
117
|
+
adapter_is :sqlite3 do
|
118
|
+
if RUBY_VERSION < '1.9'
|
119
|
+
sql.should be_like(%Q{"developers"."created_at" BETWEEN '2010-01-01 00:00:00.000000' AND '2010-02-01 00:00:00.000000'})
|
120
|
+
else
|
121
|
+
sql.should be_like(%Q{"developers"."created_at" BETWEEN '2010-01-01 00:00:00' AND '2010-02-01 00:00:00'})
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
adapter_is :postgresql do
|
126
|
+
sql.should be_like(%Q{"developers"."created_at" BETWEEN '2010-01-01 00:00:00.000000' AND '2010-02-01 00:00:00.000000'})
|
127
|
+
end
|
128
|
+
|
129
|
+
adapter_is :oracle do
|
130
|
+
sql.should be_like(%Q{"DEVELOPERS"."CREATED_AT" BETWEEN TO_TIMESTAMP('2010-01-01 00:00:00:000000','YYYY-MM-DD HH24:MI:SS:FF6') AND TO_TIMESTAMP('2010-02-01 00:00:00:000000','YYYY-MM-DD HH24:MI:SS:FF6')})
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
87
135
|
describe 'when relating to a relation' do
|
88
136
|
it 'manufactures sql with a subselect' do
|
89
137
|
sql = In.new(@attribute, @relation).to_sql
|
@@ -94,7 +142,13 @@ module Arel
|
|
94
142
|
})
|
95
143
|
end
|
96
144
|
|
97
|
-
|
145
|
+
adapter_is :oracle do
|
146
|
+
sql.should be_like(%Q{
|
147
|
+
"USERS"."ID" IN (SELECT "USERS"."ID", "USERS"."NAME" FROM "USERS")
|
148
|
+
})
|
149
|
+
end
|
150
|
+
|
151
|
+
adapter_is_not :mysql, :oracle do
|
98
152
|
sql.should be_like(%Q{
|
99
153
|
"users"."id" IN (SELECT "users"."id", "users"."name" FROM "users")
|
100
154
|
})
|
@@ -33,6 +33,12 @@ module Arel
|
|
33
33
|
("users"."id" = 1 AND "users"."name" = E'name')
|
34
34
|
})
|
35
35
|
end
|
36
|
+
|
37
|
+
adapter_is :oracle do
|
38
|
+
sql.should be_like(%Q{
|
39
|
+
("USERS"."ID" = 1 AND "USERS"."NAME" = 'name')
|
40
|
+
})
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
38
44
|
end
|
@@ -59,6 +65,12 @@ module Arel
|
|
59
65
|
("users"."id" = 1 OR "users"."name" = E'name')
|
60
66
|
})
|
61
67
|
end
|
68
|
+
|
69
|
+
adapter_is :oracle do
|
70
|
+
sql.should be_like(%Q{
|
71
|
+
("USERS"."ID" = 1 OR "USERS"."NAME" = 'name')
|
72
|
+
})
|
73
|
+
end
|
62
74
|
end
|
63
75
|
end
|
64
76
|
end
|
@@ -22,11 +22,34 @@ module Arel
|
|
22
22
|
sql.should be_like(%Q{`users`.`id`})
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
adapter_is :oracle do
|
26
|
+
sql.should be_like(%Q{"USERS"."ID"})
|
27
|
+
end
|
28
|
+
|
29
|
+
adapter_is_not :mysql, :oracle do
|
26
30
|
sql.should be_like(%Q{"users"."id"})
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
34
|
+
|
35
|
+
describe 'for an inexistent attribute' do
|
36
|
+
it "manufactures sql" do
|
37
|
+
sql = @relation[:does_not_exist].to_sql
|
38
|
+
|
39
|
+
adapter_is :mysql do
|
40
|
+
sql.should be_like(%Q{`users`.`does_not_exist`})
|
41
|
+
end
|
42
|
+
|
43
|
+
adapter_is :oracle do
|
44
|
+
sql.should be_like(%Q{"USERS"."DOEST_NOT_EXIST"})
|
45
|
+
end
|
46
|
+
|
47
|
+
adapter_is_not :mysql, :oracle do
|
48
|
+
sql.should be_like(%Q{"users"."does_not_exist"})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
30
53
|
end
|
31
54
|
end
|
32
55
|
end
|
@@ -15,7 +15,11 @@ module Arel
|
|
15
15
|
sql.should be_like(%Q{COUNT(`users`.`id`) AS `alias`})
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
adapter_is :oracle do
|
19
|
+
sql.should be_like(%Q{COUNT("USERS"."ID") AS "ALIAS"})
|
20
|
+
end
|
21
|
+
|
22
|
+
adapter_is_not :mysql, :oracle do
|
19
23
|
sql.should be_like(%Q{COUNT("users"."id") AS "alias"})
|
20
24
|
end
|
21
25
|
end
|
@@ -14,7 +14,11 @@ module Arel
|
|
14
14
|
sql.should be_like(%Q{SELECT COUNT(*) AS count_id FROM `users`})
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
adapter_is :oracle do
|
18
|
+
sql.should be_like(%Q{SELECT COUNT(*) AS count_id FROM "USERS"})
|
19
|
+
end
|
20
|
+
|
21
|
+
adapter_is_not :mysql, :oracle do
|
18
22
|
sql.should be_like(%Q{SELECT COUNT(*) AS count_id FROM "users"})
|
19
23
|
end
|
20
24
|
end
|
@@ -26,7 +30,11 @@ module Arel
|
|
26
30
|
sql.should be_like(%Q{SELECT SUM(2 * credit_limit) AS sum_id FROM `users`})
|
27
31
|
end
|
28
32
|
|
29
|
-
|
33
|
+
adapter_is :oracle do
|
34
|
+
sql.should be_like(%Q{SELECT SUM(2 * credit_limit) AS sum_id FROM "USERS"})
|
35
|
+
end
|
36
|
+
|
37
|
+
adapter_is_not :mysql, :oracle do
|
30
38
|
sql.should be_like(%Q{SELECT SUM(2 * credit_limit) AS sum_id FROM "users"})
|
31
39
|
end
|
32
40
|
end
|
@@ -27,7 +27,17 @@ module Arel
|
|
27
27
|
})
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
adapter_is :oracle do
|
31
|
+
sql.should be_like(%Q{
|
32
|
+
SELECT "USERS"."ID"
|
33
|
+
FROM "USERS"
|
34
|
+
WHERE "USERS"."ID" = 1
|
35
|
+
GROUP BY "USERS"."ID"
|
36
|
+
ORDER BY "USERS"."ID" ASC
|
37
|
+
})
|
38
|
+
end
|
39
|
+
|
40
|
+
adapter_is_not :mysql, :oracle do
|
31
41
|
sql.should be_like(%Q{
|
32
42
|
SELECT "users"."id"
|
33
43
|
FROM "users"
|
@@ -14,7 +14,11 @@ module Arel
|
|
14
14
|
sql.should be_like(%Q{DELETE FROM `users`})
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
adapter_is :oracle do
|
18
|
+
sql.should be_like(%Q{DELETE FROM "USERS"})
|
19
|
+
end
|
20
|
+
|
21
|
+
adapter_is_not :mysql, :oracle do
|
18
22
|
sql.should be_like(%Q{DELETE FROM "users"})
|
19
23
|
end
|
20
24
|
end
|
@@ -30,7 +34,15 @@ module Arel
|
|
30
34
|
})
|
31
35
|
end
|
32
36
|
|
33
|
-
|
37
|
+
adapter_is :oracle do
|
38
|
+
sql.should be_like(%Q{
|
39
|
+
DELETE
|
40
|
+
FROM "USERS"
|
41
|
+
WHERE "USERS"."ID" = 1
|
42
|
+
})
|
43
|
+
end
|
44
|
+
|
45
|
+
adapter_is_not :mysql, :oracle do
|
34
46
|
sql.should be_like(%Q{
|
35
47
|
DELETE
|
36
48
|
FROM "users"
|
@@ -50,7 +62,15 @@ module Arel
|
|
50
62
|
})
|
51
63
|
end
|
52
64
|
|
53
|
-
|
65
|
+
adapter_is :oracle do
|
66
|
+
sql.should be_like(%Q{
|
67
|
+
DELETE
|
68
|
+
FROM "USERS"
|
69
|
+
WHERE ROWNUM <= 1
|
70
|
+
})
|
71
|
+
end
|
72
|
+
|
73
|
+
adapter_is_not :mysql, :oracle do
|
54
74
|
sql.should be_like(%Q{
|
55
75
|
DELETE
|
56
76
|
FROM "users"
|
@@ -17,7 +17,14 @@ module Arel
|
|
17
17
|
})
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
adapter_is :oracle do
|
21
|
+
sql.should be_like(%Q{
|
22
|
+
SELECT "USERS"."ID", "USERS"."NAME"
|
23
|
+
FROM workers
|
24
|
+
})
|
25
|
+
end
|
26
|
+
|
27
|
+
adapter_is_not :mysql, :oracle do
|
21
28
|
sql.should be_like(%Q{
|
22
29
|
SELECT "users"."id", "users"."name"
|
23
30
|
FROM workers
|
@@ -37,7 +44,14 @@ module Arel
|
|
37
44
|
})
|
38
45
|
end
|
39
46
|
|
40
|
-
|
47
|
+
adapter_is :oracle do
|
48
|
+
sql.should be_like(%Q{
|
49
|
+
SELECT "USERS"."ID", "USERS"."NAME"
|
50
|
+
FROM users
|
51
|
+
})
|
52
|
+
end
|
53
|
+
|
54
|
+
adapter_is_not :mysql, :oracle do
|
41
55
|
sql.should be_like(%Q{
|
42
56
|
SELECT "users"."id", "users"."name"
|
43
57
|
FROM users
|
@@ -20,7 +20,15 @@ module Arel
|
|
20
20
|
})
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
adapter_is :oracle do
|
24
|
+
sql.should be_like(%Q{
|
25
|
+
SELECT "USERS"."ID", "USERS"."NAME"
|
26
|
+
FROM "USERS"
|
27
|
+
GROUP BY "USERS"."ID"
|
28
|
+
})
|
29
|
+
end
|
30
|
+
|
31
|
+
adapter_is_not :mysql, :oracle do
|
24
32
|
sql.should be_like(%Q{
|
25
33
|
SELECT "users"."id", "users"."name"
|
26
34
|
FROM "users"
|
@@ -42,7 +50,15 @@ module Arel
|
|
42
50
|
})
|
43
51
|
end
|
44
52
|
|
45
|
-
|
53
|
+
adapter_is :oracle do
|
54
|
+
sql.should be_like(%Q{
|
55
|
+
SELECT "USERS"."ID", "USERS"."NAME"
|
56
|
+
FROM "USERS"
|
57
|
+
GROUP BY asdf
|
58
|
+
})
|
59
|
+
end
|
60
|
+
|
61
|
+
adapter_is_not :mysql, :oracle do
|
46
62
|
sql.should be_like(%Q{
|
47
63
|
SELECT "users"."id", "users"."name"
|
48
64
|
FROM "users"
|
@@ -13,16 +13,25 @@ module Arel
|
|
13
13
|
|
14
14
|
adapter_is :mysql do
|
15
15
|
sql.should be_like(%Q{
|
16
|
-
SELECT `developers`.`id`, `developers`.`name`, `developers`.`salary`, `developers`.`department`
|
16
|
+
SELECT `developers`.`id`, `developers`.`name`, `developers`.`salary`, `developers`.`department`, `developers`.`created_at`
|
17
17
|
FROM `developers`
|
18
18
|
GROUP BY `developers`.`department`
|
19
19
|
HAVING MIN(salary) > 1000
|
20
20
|
})
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
adapter_is :oracle do
|
24
24
|
sql.should be_like(%Q{
|
25
|
-
SELECT "
|
25
|
+
SELECT "DEVELOPERS"."ID", "DEVELOPERS"."NAME", "DEVELOPERS"."SALARY", "DEVELOPERS"."DEPARTMENT", "DEVELOPERS"."CREATED_AT"
|
26
|
+
FROM "DEVELOPERS"
|
27
|
+
GROUP BY "DEVELOPERS"."DEPARTMENT"
|
28
|
+
HAVING MIN(salary) > 1000
|
29
|
+
})
|
30
|
+
end
|
31
|
+
|
32
|
+
adapter_is_not :mysql, :oracle do
|
33
|
+
sql.should be_like(%Q{
|
34
|
+
SELECT "developers"."id", "developers"."name", "developers"."salary", "developers"."department", "developers"."created_at"
|
26
35
|
FROM "developers"
|
27
36
|
GROUP BY "developers"."department"
|
28
37
|
HAVING MIN(salary) > 1000
|
@@ -43,6 +43,15 @@ module Arel
|
|
43
43
|
INSERT
|
44
44
|
INTO "users"
|
45
45
|
("id", "name") VALUES (1, E'nick')
|
46
|
+
RETURNING "id"
|
47
|
+
})
|
48
|
+
end
|
49
|
+
|
50
|
+
adapter_is :oracle do
|
51
|
+
@insertion.to_sql.should be_like(%Q{
|
52
|
+
INSERT
|
53
|
+
INTO "USERS"
|
54
|
+
("ID", "NAME") VALUES (1, 'nick')
|
46
55
|
})
|
47
56
|
end
|
48
57
|
end
|
@@ -74,6 +83,15 @@ module Arel
|
|
74
83
|
INSERT
|
75
84
|
INTO "users"
|
76
85
|
("name") VALUES (E'nick')
|
86
|
+
RETURNING "id"
|
87
|
+
})
|
88
|
+
end
|
89
|
+
|
90
|
+
adapter_is :oracle do
|
91
|
+
@insertion.to_sql.should be_like(%Q{
|
92
|
+
INSERT
|
93
|
+
INTO "USERS"
|
94
|
+
("NAME") VALUES ('nick')
|
77
95
|
})
|
78
96
|
end
|
79
97
|
end
|
@@ -93,13 +111,31 @@ module Arel
|
|
93
111
|
})
|
94
112
|
end
|
95
113
|
|
96
|
-
|
114
|
+
adapter_is :sqlite3 do
|
97
115
|
@insertion.to_sql.should be_like(%Q{
|
98
116
|
INSERT
|
99
117
|
INTO "users"
|
100
118
|
("id") VALUES (1)
|
101
119
|
})
|
102
120
|
end
|
121
|
+
|
122
|
+
adapter_is :postgresql do
|
123
|
+
@insertion.to_sql.should be_like(%Q{
|
124
|
+
INSERT
|
125
|
+
INTO "users"
|
126
|
+
("id") VALUES (1)
|
127
|
+
RETURNING "id"
|
128
|
+
})
|
129
|
+
end
|
130
|
+
|
131
|
+
adapter_is :oracle do
|
132
|
+
@insertion.to_sql.should be_like(%Q{
|
133
|
+
INSERT
|
134
|
+
INTO "USERS"
|
135
|
+
("ID") VALUES (1)
|
136
|
+
})
|
137
|
+
end
|
138
|
+
|
103
139
|
end
|
104
140
|
end
|
105
141
|
end
|
@@ -28,7 +28,15 @@ module Arel
|
|
28
28
|
})
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
adapter_is :oracle do
|
32
|
+
sql.should be_like(%Q{
|
33
|
+
SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID"
|
34
|
+
FROM "USERS"
|
35
|
+
INNER JOIN "PHOTOS" ON "USERS"."ID" = "PHOTOS"."USER_ID"
|
36
|
+
})
|
37
|
+
end
|
38
|
+
|
39
|
+
adapter_is_not :mysql, :oracle do
|
32
40
|
sql.should be_like(%Q{
|
33
41
|
SELECT "users"."id", "users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id"
|
34
42
|
FROM "users"
|
@@ -44,15 +52,23 @@ module Arel
|
|
44
52
|
adapter_is :mysql do
|
45
53
|
sql.should be_like(%Q{
|
46
54
|
SELECT `super_users`.`id`, `super_users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
|
47
|
-
FROM `users`
|
55
|
+
FROM `users` `super_users`
|
48
56
|
INNER JOIN `photos` ON `super_users`.`id` = `photos`.`user_id`
|
49
57
|
})
|
50
58
|
end
|
51
59
|
|
52
|
-
|
60
|
+
adapter_is :oracle do
|
61
|
+
sql.should be_like(%Q{
|
62
|
+
SELECT "SUPER_USERS"."ID", "SUPER_USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID"
|
63
|
+
FROM "USERS" "SUPER_USERS"
|
64
|
+
INNER JOIN "PHOTOS" ON "SUPER_USERS"."ID" = "PHOTOS"."USER_ID"
|
65
|
+
})
|
66
|
+
end
|
67
|
+
|
68
|
+
adapter_is_not :mysql, :oracle do
|
53
69
|
sql.should be_like(%Q{
|
54
70
|
SELECT "super_users"."id", "super_users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id"
|
55
|
-
FROM "users"
|
71
|
+
FROM "users" "super_users"
|
56
72
|
INNER JOIN "photos" ON "super_users"."id" = "photos"."user_id"
|
57
73
|
})
|
58
74
|
end
|
@@ -66,16 +82,24 @@ module Arel
|
|
66
82
|
adapter_is :mysql do
|
67
83
|
sql.should be_like(%Q{
|
68
84
|
SELECT `super_users`.`id`, `super_users`.`name`, `super_photos`.`id`, `super_photos`.`user_id`, `super_photos`.`camera_id`
|
69
|
-
FROM `users`
|
70
|
-
INNER JOIN `photos`
|
85
|
+
FROM `users` `super_users`
|
86
|
+
INNER JOIN `photos` `super_photos` ON `super_users`.`id` = `super_photos`.`user_id`
|
87
|
+
})
|
88
|
+
end
|
89
|
+
|
90
|
+
adapter_is :oracle do
|
91
|
+
sql.should be_like(%Q{
|
92
|
+
SELECT "SUPER_USERS"."ID", "SUPER_USERS"."NAME", "SUPER_PHOTOS"."ID", "SUPER_PHOTOS"."USER_ID", "SUPER_PHOTOS"."CAMERA_ID"
|
93
|
+
FROM "USERS" "SUPER_USERS"
|
94
|
+
INNER JOIN "PHOTOS" "SUPER_PHOTOS" ON "SUPER_USERS"."ID" = "SUPER_PHOTOS"."USER_ID"
|
71
95
|
})
|
72
96
|
end
|
73
97
|
|
74
|
-
adapter_is_not :mysql do
|
98
|
+
adapter_is_not :mysql, :oracle do
|
75
99
|
sql.should be_like(%Q{
|
76
100
|
SELECT "super_users"."id", "super_users"."name", "super_photos"."id", "super_photos"."user_id", "super_photos"."camera_id"
|
77
|
-
FROM "users"
|
78
|
-
INNER JOIN "photos"
|
101
|
+
FROM "users" "super_users"
|
102
|
+
INNER JOIN "photos" "super_photos" ON "super_users"."id" = "super_photos"."user_id"
|
79
103
|
})
|
80
104
|
end
|
81
105
|
end
|
@@ -95,7 +119,15 @@ module Arel
|
|
95
119
|
})
|
96
120
|
end
|
97
121
|
|
98
|
-
|
122
|
+
adapter_is :oracle do
|
123
|
+
sql.should be_like(%Q{
|
124
|
+
SELECT "USERS"."ID", "USERS"."NAME"
|
125
|
+
FROM "USERS"
|
126
|
+
INNER JOIN asdf ON fdsa
|
127
|
+
})
|
128
|
+
end
|
129
|
+
|
130
|
+
adapter_is_not :mysql, :oracle do
|
99
131
|
sql.should be_like(%Q{
|
100
132
|
SELECT "users"."id", "users"."name"
|
101
133
|
FROM "users"
|
@@ -119,7 +151,17 @@ module Arel
|
|
119
151
|
})
|
120
152
|
end
|
121
153
|
|
122
|
-
|
154
|
+
adapter_is :oracle do
|
155
|
+
sql.should be_like(%Q{
|
156
|
+
SELECT "USERS"."ID", "USERS"."NAME"
|
157
|
+
FROM "USERS"
|
158
|
+
INNER JOIN asdf ON fdsa
|
159
|
+
INNER JOIN lifo ON fifo
|
160
|
+
INNER JOIN hatful ON hallow
|
161
|
+
})
|
162
|
+
end
|
163
|
+
|
164
|
+
adapter_is_not :mysql, :oracle do
|
123
165
|
sql.should be_like(%Q{
|
124
166
|
SELECT "users"."id", "users"."name"
|
125
167
|
FROM "users"
|