-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Expo with RxDB Premium SQLite, any way to make it work #4536
Comments
From the docs
So you can use expo-sqlite in iOS, but not on android. Notice that there is a |
Thanks pubkey, Yes, I've seen the documentation page, and I'm on rxdb and rxdb-premium
some say in that issue that is just incompatible with expo. it's kind of a let down if the Premium SQLite plugin doesn't even work on android and expo, considering how big expo is in the community. If there is no proper way to set it up with the latest sdk 48, I guess we will try to make it work on rxdb-classic using expo-sqlite with memory storage, will see. |
Can you enable the logging, this might gave a clue on what is wrong. const storage = getRxStorageSQLite({
sqliteBasics: getSQLiteBasicsWebSQL(SQLite.openDatabase),
// pass log function
log: console.log.bind(console)
});
Yes expo is big. But they work on a version of SQLite that is about 3 years old and they do not want to update it. This is their fault and there is not much that I can do about that. Also the rxdb docs contain that information. The correct place to complain about that, is here |
Ok, so that's what I get when I log it using: import {
getRxStorageSQLite,
getSQLiteBasicsWebSQL,
} from 'rxdb-premium/plugins/storage-sqlite';
import sqlite2 from 'react-native-sqlite-2';
// ...
return getRxStorageSQLite({
sqliteBasics: getSQLiteBasicsWebSQL(sqlite2.openDatabase),
log: console.log.bind(console),
}); logs: LOG ## RxStorage SQLite log: open(0) sqlite_42a37798-6e4c-44b0-a0a1-2590a0431755_1678135011_1678460000420
LOG ## RxStorage SQLite log: open(0) DONE
LOG ## RxStorage SQLite log: run(1) {"query":"BEGIN;","params":[]}
# some logs outside of rxdb
LOG ## RxStorage SQLite log: run(1593) {"query":"BEGIN;","params":[]}
LOG ## RxStorage SQLite log: run(1593) ERROR
LOG open transaction error (will retry):
LOG {"name":"TypeError","message":"null is not an object (evaluating 'RNSqlite2.exec')","stack":"exec@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:265791:18\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:264884:13\ntryCallTwo@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:26518:9\ndoResolve@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:26650:25\nPromise@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:26537:14\ny@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:264883:23\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:264849:18\ngeneratorResume@[native code]\nasyncGeneratorStep@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:21753:26\n_next@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:21772:29\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:21777:14\ntryCallTwo@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:26518:9\ndoResolve@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:26650:25\nPromise@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:26537:14\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:21769:25\nrun@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:264852:29\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:263988:59\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:264147:22\ngeneratorResume@[native code]\nasyncGeneratorStep@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:21753:26\n_next@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:21772:29\ntryCallOne@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:26510:16\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:26591:27\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:27535:26\n_callTimer@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:27450:17\n_callReactNativeMicrotasksPass@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:27483:17\ncallReactNativeMicrotasks@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:27647:44\n__callReactNativeMicrotasks@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:20872:46\nhttp://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:20672:45\n__guard@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:20852:15\nflushedQueue@http://192.168.2.12:19000/index.bundle?platform=android&dev=true&hot=false:20671:21\nflushedQueue@[native code]\ncallFunctionReturnFlushedQueue@[native code]"}
# it then repeats indefinitely the last 4 logs |
Hi @jwallet, I am also looking for a good DB option to work with expo. I was actually thinking about creating my own Native Module, I think Expo have made some improvements to the API recently which makes this easier 😬 If we created our own module we could choose a SQLite library that best works with RxDB, or perhaps another DB? Would you be interested in development something together? |
@jwallet from your logs it looks like you are able to create the database connection but running the queries fails. |
@pubkey I tried it in a new env and my expo-sqlite (updated the android database to support JSON_EXTRACT) is working just fine using my npm package, but when I tried it in my project it failed on me, a different log than the one I got from sqlite2 but really similar . So I guess both should work just fine. ( I will check my expo configs. The stack is just so big, but I do know it fails even if in App I just open the simplest sqlite database setup in a hook. So probably not caused by the React code itself. Anyway, close it or keep it open, I will come back later here to leave what is causing the issue , if it can help someone else. |
So I found out the issue comes from using It did work after, but I faced a new issue after the initial sync. #4552 (same issue using react-native-sqlite-2) related to craftzdog/react-native-sqlite-2#22 |
Hello pubkey
since the source code is hidden and you are probably the only one that can answer a premium related question,
how can I make the getter
getSQLiteBasicsExpoSQLite
works with any sqlite database on expo for react-native on android?I do not want to use the pouchdb-adapter for sqlite and I tried to setup the SQLite Premium plugin with pretty much every sqlite database without success. your react-native example is running with a database in-memory which is only good for testing. your rxdb-premium sqllite says it works on react-native, I do hope it works on expo in any way.
you can see the stackoverflow post here
The text was updated successfully, but these errors were encountered: