-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: autoformat complex sql queries for easier debugging
- Loading branch information
Showing
94 changed files
with
2,753 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
77 changes: 73 additions & 4 deletions
77
tests/sqls/NextrasTests/Orm/Integration/Collection/CollectionAggregationJoinTest_testAny.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,73 @@ | ||
SELECT "authors".* FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_any" ON ("authors"."id" = "books_any"."author_id") WHERE ((("books_any"."title" = 'Book 1'))) GROUP BY "authors"."id"; | ||
SELECT COUNT(*) AS count FROM (SELECT "authors"."id" FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_any" ON ("authors"."id" = "books_any"."author_id") WHERE ((("books_any"."title" = 'Book 1'))) GROUP BY "authors"."id") temp; | ||
SELECT "authors".* FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_any" ON ("authors"."id" = "books_any"."author_id") WHERE ((("books_any"."title" = 'Book 1'))) GROUP BY "authors"."id"; | ||
SELECT COUNT(*) AS count FROM (SELECT "authors"."id" FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_any" ON ("authors"."id" = "books_any"."author_id") WHERE ((("books_any"."title" = 'Book 1'))) GROUP BY "authors"."id") temp; | ||
SELECT | ||
"authors".* | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_any" ON ( | ||
"authors"."id" = "books_any"."author_id" | ||
) | ||
WHERE | ||
( | ||
( | ||
("books_any"."title" = 'Book 1') | ||
) | ||
) | ||
GROUP BY | ||
"authors"."id"; | ||
|
||
SELECT | ||
COUNT(*) AS count | ||
FROM | ||
( | ||
SELECT | ||
"authors"."id" | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_any" ON ( | ||
"authors"."id" = "books_any"."author_id" | ||
) | ||
WHERE | ||
( | ||
( | ||
("books_any"."title" = 'Book 1') | ||
) | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
) temp; | ||
|
||
SELECT | ||
"authors".* | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_any" ON ( | ||
"authors"."id" = "books_any"."author_id" | ||
) | ||
WHERE | ||
( | ||
( | ||
("books_any"."title" = 'Book 1') | ||
) | ||
) | ||
GROUP BY | ||
"authors"."id"; | ||
|
||
SELECT | ||
COUNT(*) AS count | ||
FROM | ||
( | ||
SELECT | ||
"authors"."id" | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_any" ON ( | ||
"authors"."id" = "books_any"."author_id" | ||
) | ||
WHERE | ||
( | ||
( | ||
("books_any"."title" = 'Book 1') | ||
) | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
) temp; |
123 changes: 119 additions & 4 deletions
123
...extrasTests/Orm/Integration/Collection/CollectionAggregationJoinTest_testAnyDependent.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,119 @@ | ||
SELECT "authors".* FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_any" ON ("authors"."id" = "books_any"."author_id") LEFT JOIN "public"."authors" AS "books_translator_any" ON ("books_any"."translator_id" = "books_translator_any"."id") WHERE (("books_any"."title" = 'Book 1') AND ("books_translator_any"."id" IS NULL)) GROUP BY "authors"."id"; | ||
SELECT COUNT(*) AS count FROM (SELECT "authors"."id" FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_any" ON ("authors"."id" = "books_any"."author_id") LEFT JOIN "public"."authors" AS "books_translator_any" ON ("books_any"."translator_id" = "books_translator_any"."id") WHERE (("books_any"."title" = 'Book 1') AND ("books_translator_any"."id" IS NULL)) GROUP BY "authors"."id") temp; | ||
SELECT "authors".* FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_count" ON (("authors"."id" = "books_count"."author_id") OR (("authors"."id" = "books_count"."author_id") AND "books_count"."price" < 100)) LEFT JOIN "public"."authors" AS "books_translator_count" ON (("books_count"."translator_id" = "books_translator_count"."id") AND "books_translator_count"."id" IS NOT NULL) GROUP BY "authors"."id" HAVING ((COUNT("books_translator_count"."id") >= 1 AND COUNT("books_translator_count"."id") <= 1) OR (COUNT("books_count"."id") >= 1 AND COUNT("books_count"."id") <= 1)); | ||
SELECT COUNT(*) AS count FROM (SELECT "authors"."id" FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_count" ON (("authors"."id" = "books_count"."author_id") OR (("authors"."id" = "books_count"."author_id") AND "books_count"."price" < 100)) LEFT JOIN "public"."authors" AS "books_translator_count" ON (("books_count"."translator_id" = "books_translator_count"."id") AND "books_translator_count"."id" IS NOT NULL) GROUP BY "authors"."id" HAVING ((COUNT("books_translator_count"."id") >= 1 AND COUNT("books_translator_count"."id") <= 1) OR (COUNT("books_count"."id") >= 1 AND COUNT("books_count"."id") <= 1))) temp; | ||
SELECT | ||
"authors".* | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_any" ON ( | ||
"authors"."id" = "books_any"."author_id" | ||
) | ||
LEFT JOIN "public"."authors" AS "books_translator_any" ON ( | ||
"books_any"."translator_id" = "books_translator_any"."id" | ||
) | ||
WHERE | ||
( | ||
("books_any"."title" = 'Book 1') | ||
AND ( | ||
"books_translator_any"."id" IS NULL | ||
) | ||
) | ||
GROUP BY | ||
"authors"."id"; | ||
|
||
SELECT | ||
COUNT(*) AS count | ||
FROM | ||
( | ||
SELECT | ||
"authors"."id" | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_any" ON ( | ||
"authors"."id" = "books_any"."author_id" | ||
) | ||
LEFT JOIN "public"."authors" AS "books_translator_any" ON ( | ||
"books_any"."translator_id" = "books_translator_any"."id" | ||
) | ||
WHERE | ||
( | ||
("books_any"."title" = 'Book 1') | ||
AND ( | ||
"books_translator_any"."id" IS NULL | ||
) | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
) temp; | ||
|
||
SELECT | ||
"authors".* | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_count" ON ( | ||
( | ||
"authors"."id" = "books_count"."author_id" | ||
) | ||
OR ( | ||
( | ||
"authors"."id" = "books_count"."author_id" | ||
) | ||
AND "books_count"."price" < 100 | ||
) | ||
) | ||
LEFT JOIN "public"."authors" AS "books_translator_count" ON ( | ||
( | ||
"books_count"."translator_id" = "books_translator_count"."id" | ||
) | ||
AND "books_translator_count"."id" IS NOT NULL | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
HAVING | ||
( | ||
( | ||
COUNT("books_translator_count"."id") >= 1 | ||
AND COUNT("books_translator_count"."id") <= 1 | ||
) | ||
OR ( | ||
COUNT("books_count"."id") >= 1 | ||
AND COUNT("books_count"."id") <= 1 | ||
) | ||
); | ||
|
||
SELECT | ||
COUNT(*) AS count | ||
FROM | ||
( | ||
SELECT | ||
"authors"."id" | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_count" ON ( | ||
( | ||
"authors"."id" = "books_count"."author_id" | ||
) | ||
OR ( | ||
( | ||
"authors"."id" = "books_count"."author_id" | ||
) | ||
AND "books_count"."price" < 100 | ||
) | ||
) | ||
LEFT JOIN "public"."authors" AS "books_translator_count" ON ( | ||
( | ||
"books_count"."translator_id" = "books_translator_count"."id" | ||
) | ||
AND "books_translator_count"."id" IS NOT NULL | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
HAVING | ||
( | ||
( | ||
COUNT("books_translator_count"."id") >= 1 | ||
AND COUNT("books_translator_count"."id") <= 1 | ||
) | ||
OR ( | ||
COUNT("books_count"."id") >= 1 | ||
AND COUNT("books_count"."id") <= 1 | ||
) | ||
) | ||
) temp; |
89 changes: 85 additions & 4 deletions
89
...rasTests/Orm/Integration/Collection/CollectionAggregationJoinTest_testCountAggregator.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,85 @@ | ||
SELECT "authors".* FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_count" ON (("authors"."id" = "books_count"."author_id") AND "books_count"."price" >= 50) GROUP BY "authors"."id" HAVING ((COUNT("books_count"."id") >= 2)); | ||
SELECT COUNT(*) AS count FROM (SELECT "authors"."id" FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_count" ON (("authors"."id" = "books_count"."author_id") AND "books_count"."price" >= 50) GROUP BY "authors"."id" HAVING ((COUNT("books_count"."id") >= 2))) temp; | ||
SELECT "authors".* FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_count" ON (("authors"."id" = "books_count"."author_id") AND "books_count"."price" >= 51) GROUP BY "authors"."id" HAVING ((COUNT("books_count"."id") <= 1)); | ||
SELECT COUNT(*) AS count FROM (SELECT "authors"."id" FROM "public"."authors" AS "authors" LEFT JOIN "books" AS "books_count" ON (("authors"."id" = "books_count"."author_id") AND "books_count"."price" >= 51) GROUP BY "authors"."id" HAVING ((COUNT("books_count"."id") <= 1))) temp; | ||
SELECT | ||
"authors".* | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_count" ON ( | ||
( | ||
"authors"."id" = "books_count"."author_id" | ||
) | ||
AND "books_count"."price" >= 50 | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
HAVING | ||
( | ||
( | ||
COUNT("books_count"."id") >= 2 | ||
) | ||
); | ||
|
||
SELECT | ||
COUNT(*) AS count | ||
FROM | ||
( | ||
SELECT | ||
"authors"."id" | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_count" ON ( | ||
( | ||
"authors"."id" = "books_count"."author_id" | ||
) | ||
AND "books_count"."price" >= 50 | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
HAVING | ||
( | ||
( | ||
COUNT("books_count"."id") >= 2 | ||
) | ||
) | ||
) temp; | ||
|
||
SELECT | ||
"authors".* | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_count" ON ( | ||
( | ||
"authors"."id" = "books_count"."author_id" | ||
) | ||
AND "books_count"."price" >= 51 | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
HAVING | ||
( | ||
( | ||
COUNT("books_count"."id") <= 1 | ||
) | ||
); | ||
|
||
SELECT | ||
COUNT(*) AS count | ||
FROM | ||
( | ||
SELECT | ||
"authors"."id" | ||
FROM | ||
"public"."authors" AS "authors" | ||
LEFT JOIN "books" AS "books_count" ON ( | ||
( | ||
"authors"."id" = "books_count"."author_id" | ||
) | ||
AND "books_count"."price" >= 51 | ||
) | ||
GROUP BY | ||
"authors"."id" | ||
HAVING | ||
( | ||
( | ||
COUNT("books_count"."id") <= 1 | ||
) | ||
) | ||
) temp; |
Oops, something went wrong.