sqldelight
sqldelight copied to clipboard
Sqlite 3.25 dialect: OVER clause fails compilation
SQLDelight Version
master
Operating System
macOS
Gradle Version
7.2
Kotlin Version
1.5.31
AGP Version
No response
Describe the Bug
I wanted to try out Keyset Paging and added a query for it however compilation fails at the OVER
clause despite changing the dialect to 3.25
Stacktrace
> Task :common:generateCommonMainHockeyDbInterface FAILED
/Users/gabriel/Downloads/sqldelight/sample/common/src/commonMain/sqldelight/com/example/sqldelight/hockey/data/Player.sq: (39, 31): ')' or <expr> expected, got 'ORDER'
34 SELECT id
35 FROM (
36 SELECT
37 id,
38 CASE
39 WHEN ((row_number() OVER(ORDER BY id ASC) - 0) % :limit) = 0 THEN 1
^^^^^
40 WHEN id = :anchor THEN 1
41 ELSE 0
42 END page_boundary
Gradle Build Script
Here is a reproducer where I added the sample from the docs and set the dialect to 3.25 in the sample project: https://github.com/cashapp/sqldelight/compare/master...gabrielittner:sample-over-clause
Same issue here, any update?
@AlecStrong I took a stab at this by adding other_expr
to overrides
and adding
other_expr ::= {extension_expr} | window_function_invocation
to match the sqlite flow chart for expr
but the error is still:
')' or <expr> expected, got 'ORDER'
can you push a branch for me to look at?
https://github.com/eygraber/sqldelight/tree/repro-2799
you have to set it to override
other_expr ::= {extension_expr} | window_function_invocation {
extends = ...
implements = ...
override = true
}
Ah I had tested with that earlier but I forgot to include it in this branch. In any case, it still fails with the same error.
:+1: thanks, will take a look
Experiencing same issue here. Right now there doesn't seem to be a way to actually implement the query supplied in the docs unless I'm missing something.
@AlecStrong I took another look (and updated https://github.com/eygraber/sqldelight/tree/repro-2799 to make the failing test actually be correct sqlite) and the only thing I can think of is that something else is getting matched before window_function_invocation
; I just have no idea what it is
Has anyone found a fix or workaround? I'm also running into this using the same dialect.
To be clear, if it wasn't apparent, this is affecting me on the 3_38 dialect too
@AlecKazakova any updates regarding this problem?