Skip to content

Commit

Permalink
test tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensJourney committed Oct 23, 2023
1 parent ce0bcd7 commit 1128df9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/powersync-sdk-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"homepage": "https://docs.powersync.co/",
"peerDependencies": {
"@journeyapps/react-native-quick-sqlite": "^0.0.1",
"@journeyapps/react-native-quick-sqlite": "0.0.0-dev-20231023173642",
"base-64": "^1.0.0",
"react": "*",
"react-native-fetch-api": "^3.0.0",
Expand All @@ -40,7 +40,7 @@
"async-lock": "^1.4.0"
},
"devDependencies": {
"@journeyapps/react-native-quick-sqlite": "^0.0.1",
"@journeyapps/react-native-quick-sqlite": "0.0.0-dev-20231023173642",
"@types/async-lock": "^1.4.0",
"react": "18.2.0",
"typescript": "^4.1.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { open } from '@journeyapps/react-native-quick-sqlite';
import { open, QuickSQLite, QuickSQLiteConnection } from '@journeyapps/react-native-quick-sqlite';

import {
AbstractPowerSyncDatabase,
Expand All @@ -19,7 +19,22 @@ export class RNQSPowerSyncDatabaseOpenFactory extends AbstractPowerSyncDatabaseO
* in the options (if provided)
* https://github.com/margelo/react-native-quick-sqlite/blob/main/README.md#loading-existing-dbs
*/
return new RNQSDBAdapter(open(this.options.dbFilename, { location: this.options.dbLocation }));
const { dbFilename } = this.options;
const openOptions = { location: this.options.dbLocation };
let DB: QuickSQLiteConnection;
try {
// Hot reloads can sometimes clear global JS state, but not close DB on native side
DB = open(dbFilename, openOptions);
} catch (ex) {
if (ex.message.includes('already open')) {
QuickSQLite.close(dbFilename);
DB = open(dbFilename, openOptions);
} else {
throw ex;
}
}

return new RNQSDBAdapter(DB);
}

generateInstance(options: PowerSyncDatabaseOptions): AbstractPowerSyncDatabase {
Expand Down
10 changes: 6 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2134,10 +2134,12 @@
"@types/yargs" "^17.0.8"
chalk "^4.0.0"

"@journeyapps/[email protected]", "@journeyapps/react-native-quick-sqlite@^0.0.1":
version "0.0.1"
resolved "https://registry.npmjs.org/@journeyapps/react-native-quick-sqlite/-/react-native-quick-sqlite-0.0.1.tgz#a5b731bfc658d6c8257ef3edebf243941a69a764"
integrity sha512-vUXWngjpTFX6xCsy6Y8jd9zcI1eajIw/rWfdkpJOdnazR0SzAmrMc0ViRB6K84fWq9CmAV3DZw+GCVEHubqhSw==
"@journeyapps/[email protected]":
version "0.0.0-dev-20231023173642"
resolved "https://registry.npmjs.org/@journeyapps/react-native-quick-sqlite/-/react-native-quick-sqlite-0.0.0-dev-20231023173642.tgz#00cfd6aec9674519ffbbc06245e7ce4ce42a0bcb"
integrity sha512-Na4XDi2u5AUZw+/mflV6LLIHJJvfvJxp5uYMDZtG+4WZ4dw0NDq+sZk+U26T/IU9xgdDWlcmwVKku9dDHLt7eg==
dependencies:
lodash "^4.17.21"

"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2":
version "0.3.3"
Expand Down

0 comments on commit 1128df9

Please sign in to comment.