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

Invalid query (failing to parse) does not throw an error #820

Open
tp opened this issue Apr 2, 2024 · 0 comments · May be fixed by #821
Open

Invalid query (failing to parse) does not throw an error #820

tp opened this issue Apr 2, 2024 · 0 comments · May be fixed by #821

Comments

@tp
Copy link

tp commented Apr 2, 2024

In our app a wrong SQL statement in the form of DELETE * FROM foo (where there should be no * in the statement) snuck into a @Query annotation.

The underlying sqlparser throws a ParsingError in

https://github.com/simolus3/drift/blob/sqlparser-0.27.0/sqlparser/lib/src/reader/parser.dart#L141

which then gets converted into a InvalidStatement return value on a higher level (instead of throwing the error higher up):

https://github.com/simolus3/drift/blob/sqlparser-0.27.0/sqlparser/lib/src/reader/parser.dart#L185

But then in floor's query execution this type of "statement" is silently ignored and the error is never reported:

https://github.com/pinchbv/floor/blob/1.4.2/floor/lib/src/adapter/query_adapter.dart#L141-L152

I would suggest that the type-switch would be extended to handle InvalidStatement explicitly (forwarding the error) and then have a general fallback to throw on unknown statement types (as we can't exhaustively switch over them, as the base class is not sealed).

Does that sound a reasonable extension?

tp added a commit to tp/floor that referenced this issue Apr 2, 2024
@tp tp linked a pull request Apr 2, 2024 that will close this issue
tp added a commit to tp/floor that referenced this issue Apr 2, 2024
tp added a commit to tp/floor that referenced this issue May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant