Skip to content

Commit

Permalink
Fix tests involving .take and .drop for MS SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
kiendang committed Sep 10, 2024
1 parent 9530c47 commit c2dba92
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 114 deletions.
52 changes: 36 additions & 16 deletions scalasql/test/src/query/FlatJoinTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,42 @@ trait FlatJoinTests extends ScalaSqlSuite {
si <- ShippingInfo.select.sortBy(_.id).asc.take(1).crossJoin()
} yield (b.name, si.shippingDate)
},
sql = """
SELECT
subquery0.name AS res_0,
subquery1.shipping_date AS res_1
FROM
(SELECT buyer0.id AS id, buyer0.name AS name
FROM buyer buyer0
ORDER BY id ASC
LIMIT ?) subquery0
CROSS JOIN (SELECT
shipping_info1.id AS id,
shipping_info1.shipping_date AS shipping_date
FROM shipping_info shipping_info1
ORDER BY id ASC
LIMIT ?) subquery1
""",
sqls = Seq(
"""
SELECT
subquery0.name AS res_0,
subquery1.shipping_date AS res_1
FROM
(SELECT buyer0.id AS id, buyer0.name AS name
FROM buyer buyer0
ORDER BY id ASC
LIMIT ?) subquery0
CROSS JOIN (SELECT
shipping_info1.id AS id,
shipping_info1.shipping_date AS shipping_date
FROM shipping_info shipping_info1
ORDER BY id ASC
LIMIT ?) subquery1
""",
"""
SELECT
subquery0.name AS res_0,
subquery1.shipping_date AS res_1
FROM
(SELECT buyer0.id AS id, buyer0.name AS name
FROM buyer buyer0
ORDER BY id ASC
OFFSET ? ROWS
FETCH FIRST ? ROWS ONLY) subquery0
CROSS JOIN (SELECT
shipping_info1.id AS id,
shipping_info1.shipping_date AS shipping_date
FROM shipping_info shipping_info1
ORDER BY id ASC
OFFSET ? ROWS
FETCH FIRST ? ROWS ONLY) subquery1
"""
),
value = Seq(
("James Bond", LocalDate.parse("2010-02-03"))
),
Expand Down
31 changes: 22 additions & 9 deletions scalasql/test/src/query/SelectTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,28 @@ trait SelectTests extends ScalaSqlSuite {
)
)
},
sql = """
SELECT
product0.name AS res_0,
(SELECT purchase1.total AS res
FROM purchase purchase1
WHERE (purchase1.product_id = product0.id)
ORDER BY res DESC
LIMIT ?) AS res_1
FROM product product0""",
sqls = Seq(
"""
SELECT
product0.name AS res_0,
(SELECT purchase1.total AS res
FROM purchase purchase1
WHERE (purchase1.product_id = product0.id)
ORDER BY res DESC
LIMIT ?) AS res_1
FROM product product0
""",
"""
SELECT
product0.name AS res_0,
(SELECT purchase1.total AS res
FROM purchase purchase1
WHERE (purchase1.product_id = product0.id)
ORDER BY res DESC
OFFSET ? ROWS FETCH FIRST ? ROWS ONLY) AS res_1
FROM product product0
"""
),
value = Seq(
("Face Mask", 888.0),
("Guitar", 900.0),
Expand Down
Loading

0 comments on commit c2dba92

Please sign in to comment.