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

Error on query with RETURNING keyword on Android #575

Open
kshehata opened this issue May 19, 2024 · 1 comment
Open

Error on query with RETURNING keyword on Android #575

kshehata opened this issue May 19, 2024 · 1 comment

Comments

@kshehata
Copy link

My app works perfectly on iOS, and I'm trying to port it to Android. Any time I run a query with the Returning keyword I get the error below:

unknown error (code 0 SQLITE_OK): Queries can be performed using SQLiteDatabase query or rawQuery methods only.

I tried adding a react-native.config.js file as per the instructions, but I get the same error. I really don't want to have different code for Android and iOS. How do I get these queries to work? Is there a "raw query" mode?

Expected Behavior

db.executeSql("INSERT INTO MyTable VALUES (...) RETURNING rowid");

Should add a new row to the table and return the rowid, exactly as it does on iOS.

Current Behavior

Get error above, no rowid.

Possible Solution

Make it work the same as iOS?

Or if that's not possible, make a executeRawSql() interface?

Steps to Reproduce (for bugs)

As above, create a table, and try to insert a row and return the rowid. On Android it returns an error. On iOS it works.

Context

Seems like iOS and Android interfaces differ.

Your Environment

  • React Native SQLite Storage Version used: 6.0.1
  • React Native version used: 0.72.6
  • Operating System and version (simulator or device): Android Studio Pixel 3A emulator, Android 34 (upside down cake)
  • IDE used: Android Studio / command line React Native Tools
  • Link to your project:

Debug logs

@kshehata
Copy link
Author

As a workaround, I've gotten rid of the RETURNING statements, so now it does:

await db.executeSql("INSERT INTO MyTable VALUES (...)", ...);
const rowid = await db.executeSql("SELECT last_insert_rowid() as rowid");

This seems to do the job for now, but still frustrating that they're different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant