-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqlite: Invalid SQL for reused alias? #27129
Comments
@roji - Does this test work correctly on postgre? |
It's currently skipped in EF (#27130). I copy-pasted the LINQ query from the base: await AssertQuery(
async,
ss => ss.Set<Order>().GroupBy(e => e.CustomerID)
.Select(
g => new
{
g.Key,
A = ss.Set<Employee>().Where(e => e.City == "Seattle").GroupBy(e => e.City)
.Select(g2 => g2.Count() + g.Count())
.OrderBy(e => e)
.FirstOrDefault()
}),
elementSorter: e => e.Key); This produces the following SQL which PG executes successfully: SELECT o."CustomerID" AS "Key", COALESCE((
SELECT count(*)::int + count(*)::int
FROM "Employees" AS e
WHERE e."City" = 'Seattle'
GROUP BY e."City"
ORDER BY count(*)::int + count(*)::int NULLS FIRST
LIMIT 1), 0) AS "A"
FROM "Orders" AS o
GROUP BY o."CustomerID" The SQL works, but the test fails with:
... maybe some ordering/non-determinism issue... that's usually what it means. Let me know if you need more info on this! |
The count(*) are unreferenced so the error is not ordering issue but the #27130 |
Another question for @roji |
Content for issue filing on Sqlite forum
|
@smitpatel yeah, in EF 6.0 the test passes (GroupBy_aggregate_from_multiple_query_in_same_projection_3), in 7.0 the SQL works but fails the AssertQuery check. Below are the SQLs I'm seeing in both cases, let me know if you want more info. EF 7.0 (SQL works, AssertQuery fails): SELECT o."CustomerID" AS "Key", COALESCE((
SELECT count(*)::int + count(*)::int
FROM "Employees" AS e
WHERE e."City" = 'Seattle'
GROUP BY e."City"
ORDER BY count(*)::int + count(*)::int NULLS FIRST
LIMIT 1), 0) AS "A"
FROM "Orders" AS o
GROUP BY o."CustomerID" EF 6.0 (test passes): SELECT o."CustomerID" AS "Key", COALESCE((
SELECT COUNT(*)::INT + (
SELECT COUNT(*)::INT
FROM "Orders" AS o0
WHERE (o."CustomerID" = o0."CustomerID") OR (((o."CustomerID" IS NULL)) AND ((o0."CustomerID" IS NULL))))
FROM "Employees" AS e
WHERE e."City" = 'Seattle'
GROUP BY e."City"
ORDER BY COUNT(*)::INT + (
SELECT COUNT(*)::INT
FROM "Orders" AS o0
WHERE (o."CustomerID" = o0."CustomerID") OR (((o."CustomerID" IS NULL)) AND ((o0."CustomerID" IS NULL)))) NULLS FIRST
LIMIT 1), 0) AS "A"
FROM "Orders" AS o
GROUP BY o."CustomerID" |
Test GroupBy_aggregate_from_multiple_query_in_same_projection_3
Generated SQL
Throws
Not sure the reason. Same SQL works fine on SqlServer.
The text was updated successfully, but these errors were encountered: