Skip to content
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

First() and Last() methods break in Sqlite provider #23

Open
AdamIzon opened this issue Jan 17, 2025 · 1 comment
Open

First() and Last() methods break in Sqlite provider #23

AdamIzon opened this issue Jan 17, 2025 · 1 comment

Comments

@AdamIzon
Copy link

AdamIzon commented Jan 17, 2025

When I call IQueryable.First() or IQueryable.Last(), I get the exception [SQLite Error 1: 'near "FETCH": syntax error'].
When I look at the debug view on the IQueryable object before calling First() or Last() there is no "FETCH" in the SQL query, so First() and Last() must be adding this.

When I remove this package from my project this behaviour goes away.

@AdamIzon AdamIzon changed the title Breaks Sqlite provider First() and Last() methods break in Sqlite provider Jan 19, 2025
@AdamIzon
Copy link
Author

AdamIzon commented Jan 19, 2025

Example:

For the given LINQ:

var blockades = _dbContext.Blockade;
var testQuery = blockades.Select(b => EF.Functions.RowNumber(EF.Functions.Over().OrderBy((long)b.BlockadeStartIndex)));
var average = testQuery.First();

The SQL code being generated is

SELECT ROW_NUMBER() OVER(ORDER BY CAST("b"."BlockadeStartIndex" AS INTEGER))
FROM "Blockade" AS "b"
WHERE "b"."RecordingId" = @__recording_Id_0
ORDER BY CAST("b"."BlockadeStartIndex" AS INTEGER)
FETCH FIRST 1 ROWS ONLY

but to clarify, this breaks any call to IQueryable.First()... not just queries containing window functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant