Skip to content

Conversation

simolus3
Copy link
Contributor

This adds a new project in the integrations folder that provides a single class: PowerSyncDriver. That class implements the SqlDriver interface from SQLDelight by forwarding queries and statements to an opened PowerSync database.

Additionally, query listeners in that driver are backed by PowerSyncDatabase.onChange, meaning that all changes between the original powersync database and the SQLDelight wrapper are visible to each other and cause reactive updates. An obvious but still pretty cool result is that updates from the sync client also trigger updates to flows in SQLDelight.

I've added a test project to run unit tests against a SQLDelight database, but no real example yet.

@Radiokot
Copy link
Contributor

I just tried SQLDelight and I really liked how much safety it does bring to the creation of queries and mapping the results. Would be happy to use it on PowerSync views.

Base automatically changed from refactor-drivers to main September 9, 2025 17:54
@simolus3 simolus3 marked this pull request as ready for review September 10, 2025 11:44
@simolus3 simolus3 changed the base branch from main to room September 17, 2025 10:45
Copy link
Contributor

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

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

Left some comments. This looks amazing! Happy with the implementation.

stevensJourney
stevensJourney previously approved these changes Sep 17, 2025
Copy link
Contributor

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

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

🚀

Base automatically changed from room to main September 17, 2025 15:22
@simolus3 simolus3 dismissed stevensJourney’s stale review September 17, 2025 15:22

The base branch was changed.

An error occurred while trying to automatically change base from room to main September 17, 2025 15:22
@simolus3 simolus3 merged commit 0d56088 into main Sep 17, 2025
7 checks passed
@simolus3 simolus3 deleted the sqldelight branch September 17, 2025 17:42
@Radiokot
Copy link
Contributor

Simon, I see you suggest linkSqlite.set(false) in the SQLDelight gradle plugin configuration. But what if I already use SQLDelight for the local database in my app? Would I be able to use them simultaneously using SQLite native lib from PowerSync?

@simolus3
Copy link
Contributor Author

Would I be able to use them simultaneously using SQLite native lib from PowerSync?

Yes, I think that should work. It's also worth mentioning that linkSqlite only applies to native targets, SQLDelight uses platform APIs on Android. And on native platforms linking SQLite is not required because PowerSync links it for you, so SQLDelight should just work. Let me know if you run into any issues with that though.

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.

3 participants