Skip to content

Conversation

@stevensJourney
Copy link
Collaborator

Overview

This fixes a regression from #211.

The PR above introduced the ability to directly construct a PowerSyncDatabase. The AbstractPowerSyncDatabase accepts either an instance of DBAdapter, a SQLite open factory which will be used to open a DBAdapter or options to be used with a default SQLite open factory.

If options are provided the AbstractPowerSyncDatabase constructor will call the abstract openDBAdapter method with SQLOpenOptions.

Web implementations require additional flags when opening SQLite connections. The implementation previously assumed the resolvedFlags were available in the openAdapter method. This is not the case since the super() method is called before the resolved flags are assigned. This would cause the supplied flags to be ignored when creating DB connections. In practise this disregarded the useWebWorker flag.

This PR updates the internal and protected openAdapter method to have access to all the options provided to the PowerSyncDatabase constructor.

Unit tests have been added to ensure workers are correctly used given the relevant flags.

@changeset-bot
Copy link

changeset-bot bot commented Jul 29, 2024

🦋 Changeset detected

Latest commit: 445e3c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@powersync/common Patch
@powersync/web Patch
@powersync/react-native Patch
@powersync/diagnostics-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

},
"license": "MIT",
"dependencies": {
"@emotion/react": "^11.13.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this was required in a standalone demo during testing.

@stevensJourney stevensJourney marked this pull request as ready for review July 29, 2024 09:59
@stevensJourney stevensJourney merged commit 32e342a into main Jul 29, 2024
@stevensJourney stevensJourney deleted the fix/sql-options branch July 29, 2024 11:00
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

Successfully merging this pull request may close these issues.

4 participants