diff options
author | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-02-10 19:50:59 +0200 |
---|---|---|
committer | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-03-01 12:02:10 +0200 |
commit | 20a10e5302ce8f912d27c57702b542a019c7f9f9 (patch) | |
tree | 38de3309520244ba6fda99b8d47525852e926491 /spec/arel/engines/sql/integration | |
parent | 98a87e181aed8131797e55db2ca957bc515cdaca (diff) | |
download | rails-20a10e5302ce8f912d27c57702b542a019c7f9f9.tar.gz rails-20a10e5302ce8f912d27c57702b542a019c7f9f9.tar.bz2 rails-20a10e5302ce8f912d27c57702b542a019c7f9f9.zip |
changes for Oracle support - OracleCompiler and corresponding tests with Oracle syntax
Diffstat (limited to 'spec/arel/engines/sql/integration')
3 files changed, 147 insertions, 14 deletions
diff --git a/spec/arel/engines/sql/integration/joins/with_adjacency_spec.rb b/spec/arel/engines/sql/integration/joins/with_adjacency_spec.rb index 37afb1a8f2..47d37415ae 100644 --- a/spec/arel/engines/sql/integration/joins/with_adjacency_spec.rb +++ b/spec/arel/engines/sql/integration/joins/with_adjacency_spec.rb @@ -22,7 +22,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME" + FROM "USERS" + INNER JOIN "USERS" "USERS_2" + ON "USERS"."ID" = "USERS_2"."ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name" FROM "users" @@ -48,7 +57,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME" + FROM "USERS" + INNER JOIN "USERS" "USERS_2" + ON "USERS"."ID" = "USERS_2"."ID" AND "USERS_2"."ID" = 1 + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name" FROM "users" @@ -76,7 +94,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME" + FROM "USERS" + INNER JOIN "USERS" "USERS_2" + ON "USERS_2"."ID" = "USERS"."ID" AND "USERS_2"."ID" = 1 + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name" FROM "users" @@ -113,7 +140,18 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME", "USERS_3"."ID", "USERS_3"."NAME" + FROM "USERS" + INNER JOIN "USERS" "USERS_2" + ON "USERS"."ID" = "USERS_2"."ID" + INNER JOIN "USERS" "USERS_3" + ON "USERS_2"."ID" = "USERS_3"."ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name", "users_3"."id", "users_3"."name" FROM "users" @@ -144,7 +182,18 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME", "USERS_3"."ID", "USERS_3"."NAME" + FROM "USERS" + INNER JOIN "USERS" "USERS_2" + ON "USERS"."ID" = "USERS_2"."ID" + INNER JOIN "USERS" "USERS_3" + ON "USERS_2"."ID" = "USERS_3"."ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name", "users_3"."id", "users_3"."name" FROM "users" diff --git a/spec/arel/engines/sql/integration/joins/with_aggregations_spec.rb b/spec/arel/engines/sql/integration/joins/with_aggregations_spec.rb index 5ed530508a..1ed056ca59 100644 --- a/spec/arel/engines/sql/integration/joins/with_aggregations_spec.rb +++ b/spec/arel/engines/sql/integration/joins/with_aggregations_spec.rb @@ -29,7 +29,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS_EXTERNAL"."ID", "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CAMERA_ID" + FROM "USERS" + INNER JOIN (SELECT "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID" FROM "PHOTOS" WHERE ROWNUM <= 3) "PHOTOS_EXTERNAL" + ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "photos_external"."id", "photos_external"."user_id", "photos_external"."camera_id" FROM "users" @@ -52,7 +61,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CNT" + FROM "USERS" + INNER JOIN (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL" + ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "photos_external"."user_id", "photos_external"."cnt" FROM "users" @@ -76,7 +94,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CNT", "USERS"."ID", "USERS"."NAME" + FROM (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL" + INNER JOIN "USERS" + ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "photos_external"."user_id", "photos_external"."cnt", "users"."id", "users"."name" FROM (SELECT "photos"."user_id", COUNT("photos"."id") AS "cnt" FROM "photos" GROUP BY "photos"."user_id") AS "photos_external" @@ -101,7 +128,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CNT", "PHOTOS_EXTERNAL_2"."USER_ID", "PHOTOS_EXTERNAL_2"."CNT" + FROM (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL" + INNER JOIN (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL_2" + ON "PHOTOS_EXTERNAL_2"."USER_ID" = "PHOTOS_EXTERNAL"."USER_ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "photos_external"."user_id", "photos_external"."cnt", "photos_external_2"."user_id", "photos_external_2"."cnt" FROM (SELECT "photos"."user_id", COUNT("photos"."id") AS "cnt" FROM "photos" GROUP BY "photos"."user_id") AS "photos_external" @@ -126,7 +162,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CNT" + FROM "USERS" + INNER JOIN (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" WHERE "PHOTOS"."USER_ID" = 1 GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL" + ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "photos_external"."user_id", "photos_external"."cnt" FROM "users" @@ -150,7 +195,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CNT", "USERS"."ID", "USERS"."NAME" + FROM (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" WHERE "PHOTOS"."USER_ID" = 1 GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL" + INNER JOIN "USERS" + ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "photos_external"."user_id", "photos_external"."cnt", "users"."id", "users"."name" FROM (SELECT "photos"."user_id", COUNT("photos"."id") AS "cnt" FROM "photos" WHERE "photos"."user_id" = 1 GROUP BY "photos"."user_id") AS "photos_external" diff --git a/spec/arel/engines/sql/integration/joins/with_compounds_spec.rb b/spec/arel/engines/sql/integration/joins/with_compounds_spec.rb index 5909716542..65fe49d128 100644 --- a/spec/arel/engines/sql/integration/joins/with_compounds_spec.rb +++ b/spec/arel/engines/sql/integration/joins/with_compounds_spec.rb @@ -26,7 +26,16 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID" + FROM "USERS" + INNER JOIN "PHOTOS" + ON "USERS"."ID" = "PHOTOS"."USER_ID" AND asdf + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id" FROM "users" @@ -59,7 +68,18 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID" + FROM "USERS" + INNER JOIN "PHOTOS" + ON "USERS"."ID" = "PHOTOS"."USER_ID" + WHERE "USERS"."ID" = 1 + AND "USERS"."ID" = 1 + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id" FROM "users" @@ -90,7 +110,17 @@ module Arel }) end - adapter_is_not :mysql do + adapter_is :oracle do + sql.should be_like(%Q{ + SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID" + FROM "USERS" + INNER JOIN "PHOTOS" + ON "USERS"."ID" = "PHOTOS"."USER_ID" + GROUP BY "USERS"."ID" + }) + end + + adapter_is_not :mysql, :oracle do sql.should be_like(%Q{ SELECT "users"."id", "users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id" FROM "users" |