Status Update
Comments
da...@google.com <da...@google.com> #2
Can you confirm if the issue is present in the latest alpha version of Room, i.e. 2.7.0-alpha11
?
room-compiler has its own SQL grammar that it uses to validate queries at compile-time and we updated it back in April (3.24
where as in Room 2.7.x the grammar was updated to support the syntax in SQLite version 3.41
.
pa...@gmail.com <pa...@gmail.com> #3
pa...@gmail.com <pa...@gmail.com> #4
After updating Room to 2.7.0-alpha11, the issue seems to be fixed, but there is still a style error (see attached image).
So the application runs (something that it did not do in 2.6.1
), but there is still a style error.
da...@google.com <da...@google.com> #5
Which version of Android Studio are you using? The IDE 'style error' seems to be coming from Android Studio's SQL parser which unfortunately is also different from room-compiler.
pa...@gmail.com <pa...@gmail.com> #6
I am not using Android Studio, I am using IntelliJ with the Android plugin. I hope that's not a problem. My IntelliJ version is 2024.2.1 and with Android plugin version 242.21829.142.
I think this corresponds to Android Studio Koala, but don't quote me on that. That's just info from a quick Google search
da...@google.com <da...@google.com> #7
Oh! If you are not using Android Studio then the styler must be part of
Thanks for confirming at least that room-compiler no longer shows an error on version 2.7.x. By the way if you don't feel good about using Room 2.7.0-alpha in your project you can always tell Room to skip query verification on a query it can't understand by annotating the DAO function with @SkipQueryVerification
along-side the @Query
.
pa...@gmail.com <pa...@gmail.com> #8
I installed and opened the project in Android Studio Ladybug | 2024.2.1 Patch 2, and there I also have the style issue.
I looked at the language injection link that you sent, and opened my language injection settings in IntelliJ. Specifically for the @Query
annotation, it seems that it already links to Android Room SQL (see attached image). Honestly, I don't really have a clue of what the language injection settings exactly do too. But as you can see it links back to Android Room.
Nonetheless, again, the style error also appears in Android Studio.
EDIT: in case you want to know, the language injection settings in Android Studio give the exact same as the attached image for IntelliJ.
da...@google.com <da...@google.com> #9
Ok - Then seems I was wrong in terms of where the SQL syntax parser is for Room in the IDE, might indeed be coming from the Android Plugin. But if you see the issue in Android Studio too, then it seems to be a problem in their version of SQL syntax.
I think in terms of Room, there is no action item for us. As for the IDE syntax, I have re-routed this bug to the studio team.
an...@google.com <an...@google.com> #10
Yeah, it looks like we just need to update the grammar in Android Studio for this.
I can confirm that IntelliJ uses some of the open source part of Android Studio for their Android plugin, and that includes our parsing of the query in this case. So once we fix it in Studio, whenever they merge our code next it'll be incorporated into IntelliJ. (I'm not familiar with what their schedule is for that, but I expect it would lag by about 1 major version.)
Assigning this to myself, and will look at making a fix hopefully next week.
an...@google.com <an...@google.com>
kd...@google.com <kd...@google.com>
kd...@google.com <kd...@google.com>
an...@google.com <an...@google.com> #11
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Meerkat | 2024.3.1 Canary 4
- Android Gradle Plugin 8.9.0-alpha04
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
Component used: Room
Version used: 2.6.1
Devices/Android versions reproduced on: 7.6 Fold-in with outer display. Android API 34.
Issue Description
Since SQLite version 3.25.0, SQLite supports window functions . This includes queries such as
ROW_NUMBER() OVER (PARTITION BY ...)
. However, after theOVER
and on the(
parenthesis, it gives a style-check erorr:<compound operator>, FROM, GROUP, LIMIT, ORDER, WHERE or comma expected, got '('
.There are many Stackoverflow issues describing this issue:
But all these issues date back from years ago, when Room was still using SQLite versions below 3.25.0.
Currently, according to your own API-SQLite conversion table , Room uses SQLite 3.39-3.42.0 as of API 34. So it does support window functions. The page also says that SQLite versions may differ per device, but I already confirmed that on my own device, I use SQLite version 3.39.2.
So even though my SQLite version is high enough to actually support window functions, Room doesn't allow me to run the query because the query cannot be parsed. At least, I think it's a parsing problem because when I use a raw query to run the query (so basically just running a query without the style checks of Room), my query just runs perfectly and actually queries the data like it should. So that signals no problems of SQLite itself.
I'll give a coding example, so you can reproduce it. Create a databate and tables as usual. Then, in your DAO class, you write a query for the database:
Where
<My Query>
is a query that uses a window function (likeROW_NUMBER() OVER (...)
for example). You should then see an error at the first(
parenthesis afterOVER
.However, when just using a raw query:
gives no problems. Here, you would pass
ssq
toqueryMethod
, and you would see that executing it does not give errors and returns your queried data.To be fixed
Allow the use of windows functions in
@Query("...")
annotations, without causing errors. Again, this is probably a parsing error in Room, not an error caused by SQLite.