sqldelight
sqldelight copied to clipboard
Add more checks for statements with parameters
Description
I was under impression that queries like these will work:
deletePractice:
DELETE FROM practice WHERE id=:id;
DELETE FROM practice_entry WHERE practice_id=:id;
deletePractices:
DELETE FROM practice WHERE id IN :practiceIds;
DELETE FROM practice_entry WHERE practice_id IN :practiceIds;
Android driver instantly gave me an runtime error and upon investigating I noticed that second statements were executed during database creation and have no parameters detected
I think there should be more checks for detecting parameters where they're not working. Maybe even forbid to have multiple statements after you start defining methods so all database creation statements would be located at the top
I think you just need to use this syntax https://cashapp.github.io/sqldelight/2.0.1/android_sqlite/grouping_statements/ My guess is that the second line is interpreted independently from the function name and gets run during creation otherwise
Yes, this is what I used to fix this, but I think it should be an error when there're invalid parameters in the database creation queries that will make app crash in runtime
Ah sorry I misread the issue, seems like a good idea
Personally, I think, we should split sql declarations (including delete statements!) and actual user queries in separate files (and languages). This also allows us to get rid of the grouping transaction syntax.