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

[sqlite] add builtin support to import existing db #28291

Merged
merged 5 commits into from
Apr 19, 2024

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Apr 18, 2024

Why

it's good to save the way to import existing db
close ENG-11804

How

asides from #28289 and #28290. this pr tries to add a SQLiteProvider.assetSource for the builtin support.

Test Plan

since we don't have testing infra to test hook inside test-suite, i have to do it manually:

  <SQLiteProvider
    databaseName="test.db"
    assetSource={{ assetId: require('./assets/test.db'), forceOverwrite: true }}>
    <Children>
  </SQLiteProvider>
 const db = useSQLiteContext();
 React.useEffect(() => {
   async function runAsync() {
     const result = await db.getAllAsync('SELECT * FROM test');
     console.log('result', result);
     await db.runAsync('INSERT INTO test (name) VALUES (?)', ['test']);
     const result2 = await db.getAllAsync('SELECT * FROM test');
     console.log('result2', result2);
   }
   runAsync();
 }, []);

reload the app the result would keep the same.
after remove the forceOverwrite: true and reload a couple times, the result would keep growing.

tested on android and ios bare-expo.

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Apr 18, 2024
@Kudo Kudo mentioned this pull request Apr 18, 2024
3 tasks
@expo-bot
Copy link
Collaborator

expo-bot commented Apr 18, 2024

The Pull Request introduced fingerprint changes against the base commit: d735716

Fingerprint diff
[
  {
    "type": "dir",
    "filePath": "../../packages/expo-sqlite/android",
    "reasons": [
      "expoAutolinkingAndroid"
    ],
    "hash": "85d53956059caa15c534a2f97f9b994c430ade2b"
  },
  {
    "type": "dir",
    "filePath": "../../packages/expo-sqlite/ios",
    "reasons": [
      "expoAutolinkingIos"
    ],
    "hash": "d193a624d37fc296fb91375b3fb5257f7608a68d"
  }
]

Generated by PR labeler 🤖

@Kudo Kudo force-pushed the @kudo/sqlite/builtin-import-existing-db branch from e0fdf0e to 43f0a64 Compare April 18, 2024 16:13
@Kudo Kudo changed the base branch from main to @kudo/reexport-asset April 18, 2024 16:13
@Kudo Kudo marked this pull request as ready for review April 18, 2024 17:30
@Kudo Kudo force-pushed the @kudo/sqlite/builtin-import-existing-db branch from ef6a6a0 to c72557e Compare April 19, 2024 16:57
@Kudo Kudo changed the base branch from @kudo/reexport-asset to main April 19, 2024 16:57
Copy link

linear bot commented Apr 19, 2024

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Apr 19, 2024
@Kudo Kudo merged commit f8790aa into main Apr 19, 2024
26 checks passed
@Kudo Kudo deleted the @kudo/sqlite/builtin-import-existing-db branch April 19, 2024 18:08
@brentvatne brentvatne added the published Changes from the PR have been published to npm label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants