react-native-sqlite-storage
react-native-sqlite-storage copied to clipboard
Promise based executeSql does not throw any errors for invalid SQL
When running executeSql(statement: string, params?: any[]): Promise<[ResultSet]>;
and providing invalid SQL such as INSERT INTO Unknown ();
does not result in any errors thrown, but logs to console.
Expected Behavior
Since this is a promise based return, it should be throwing an error if any issue comes up which can then be caught in a try/catch (or with a then/catch, both should work).
Current Behavior
No errors thrown, error is only logged to console.
Steps to Reproduce (for bugs)
Run any invalid sql using the promise based version of executeSql
with a try/catch and see that the catch never triggers.
Your Environment
- React Native SQLite Storage Version used: 4.1.0
- React Native version used: 0.62.1
- Operating System and version (simulator or device): macOS 10.15.4, Android 10 (Api level 29)
- IDE used: IntelliJ Ultimate 2020.1
same :+1:
Pleaase, solve this issue
Bumping this because it seems like a fairly large oversight imo @andpor
Thanks for looking at this @MichaelKovich.
Unfortunately I do indeed await the promise. db.executeSql()
itself is a promise and doing await db.executeSql()
should be sufficient without having to wrap it in another promise. This appears to be a bug with the library itself because the api promises (ha, promise) that it will return an awaitable promise but your example is trying to fix the fact that it isn't working like advertised
@josephmbeveridge does it still happen? It seems to work fine when I provide the invalid SQL (INSERT INTO Unknown ();
). I'm using version 6.0.1.