react-native-sqlite-storage icon indicating copy to clipboard operation
react-native-sqlite-storage copied to clipboard

Promise based executeSql does not throw any errors for invalid SQL

Open josephmbeveridge opened this issue 4 years ago • 5 comments

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

josephmbeveridge avatar May 22 '20 21:05 josephmbeveridge

same :+1:

ChangeSomeCode avatar May 27 '20 12:05 ChangeSomeCode

Pleaase, solve this issue

Temirtator avatar Jun 08 '20 12:06 Temirtator

Bumping this because it seems like a fairly large oversight imo @andpor

josephmbeveridge avatar Aug 19 '20 18:08 josephmbeveridge

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 avatar Jan 14 '21 16:01 josephmbeveridge

@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.

SufianBabri avatar Dec 03 '22 15:12 SufianBabri