react-native-sqlite-storage
react-native-sqlite-storage copied to clipboard
How to use SQLIte 3.26.0 instead of 3.22.0 in order to support UPSERTs ?
Hello guys! I'm developing a react-native application using typeorm and typeorm uses your library in order to offer SQLite support for react-native users.
I really need to use UPSERT feature on some of my queries, but when i check the SQLite version (select sqlite_version()) it says i'm on version 3.22.0.
Already tried to change react-native-config.js to use android-native version, the code is below:
module.exports = {
project: {
ios: {},
android: {},
},
assets: ['./assets/fonts/'],
dependencies: {
'react-native-sqlite-storage': {
platforms: {
android: {
sourceDir:
'../node_modules/react-native-sqlite-storage/platforms/android-native',
packageImportPath: 'import io.liteglue.SQLitePluginPackage;',
packageInstance: 'new SQLitePluginPackage()',
},
},
},
},
}
But no luck... can you pls point me to an ideia in order to solve that?
Thank you so much!
Expected Behavior
Use UPSERT SQLite features (ON CONFLICT DO UPDATE)....
The query should complete without errors.
Current Behavior
When i try to run this query:
INSERT INTO "theme"("id", "name", "is_active", "created_at", "updated_at") VALUES (1, "Marketing e Vendas", 0, datetime('now'), "2020-12-15 03:00:00.000"), (2, "Marketing Digital", 0, datetime('now'), "2020-12-15 03:00:00.000"), (3, "Finanças", 0, datetime('now'), "2020-12-15 03:00:00.000"), (4, "Acesso a Crédito", 0, datetime('now'), "2020-12-15 03:00:00.000"), (5, "Liderança e Pessoas", 0, datetime('now'), "2020-12-15 03:00:00.000"), (6, "Estratégia e Gestão", 0, datetime('now'), "2020-12-15 03:00:00.000"), (7, "Inovação e Tecnologia", 0, datetime('now'), "2020-12-15 03:00:00.000"), (8, "Leis e Impostos - MEI", 0, datetime('now'), "2020-12-15 03:00:00.000") ON CONFLICT('id') DO UPDATE SET name=excluded.name is_active=excluded.is_active updated_at=excluded.updated_at;
SQLite is throwing the following error:
{"message":"near \"ON\": syntax error (code 1 SQLITE_ERROR): , while compiling: INSERT INTO \"theme\"(\"id\", \"name\", \"is_active\", \"created_at\", \"updated_at\") VALUES (1, \"Marketing e Vendas\", 0, datetime('now'), \"2020-12-15 03:00:00.000\"), (2, \"Marketing Digital\", 0, datetime('now'), \"2020-12-15 03:00:00.000\"), (3, \"Finanças\", 0, datetime('now'), \"2020-12-15 03:00:00.000\"), (4, \"Acesso a Crédito\", 0, datetime('now'), \"2020-12-15 03:00:00.000\"), (5, \"Liderança e Pessoas\", 0, datetime('now'), \"2020-12-15 03:00:00.000\"), (6, \"Estratégia e Gestão\", 0, datetime('now'), \"2020-12-15 03:00:00.000\"), (7, \"Inovação e Tecnologia\", 0, datetime('now'), \"2020-12-15 03:00:00.000\"), (8, \"Leis e Impostos - MEI\", 0, datetime('now'), \"2020-12-15 03:00:00.000\") ON CONFLICT('id') DO UPDATE SET name=excluded.name is_active=excluded.is_active updated_at=excluded.updated_at;","code":3}
Possible Solution
Steps to Reproduce (for bugs)
Context
Your Environment
- React Native SQLite Storage Version used: 5.0.0
- React Native version used: 0.63.3
- Operating System and version (simulator or device): Android 9 (simulator and device, the same)
- IDE used: VSCODE
- Link to your project:
Debug logs
Same problem for me, but in my case I need to use the version 3.29.0 and above due to fix of the rounding behaviour in 3.29.0
Hi, would be nice to get some feedback on this issue. Would be nice for mobile app to be able to efficiently update local content from a remote server.