-
Notifications
You must be signed in to change notification settings - Fork 513
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
Support for async drivers #1942
Comments
I'm having a look at sqldelight/drivers Jasync natively returns a Future which i can convert to a Coroutine, this driver might be slightly different to the other ones, let me hack around a bit and see if i can get it working . |
The generated code currently assumes a synchronous API to execute the queries, you could implement the SqlDriver interface but then you’d just block on the Future you get back so I’m not sure if that helps? We’d need to do a pretty major overhaul to have the generated code use coroutines If the goal is just to use the Jasync runtime then I think implementing SqlDriver and blocking on the Jasync Futures is probably the way to go |
I want to mention a potential use case: an IndexedDB driver for Web (bridged via packages like SQLWeb). AFAIK, IndexedDB is currently the only viable database solution that supports sharing with Web Workers, especially now with Web SQL being axed. It doesn't have synchronous query API in the standard, and there is no way in ECMAScript standard to do a blocking wait on |
For my use-case, blocking anywhere was a dealbreaker and it looked like an enormous refactor to get this into SQL Delight. On the JDBC side, it's probably going to be a while before LOOM makes it into JDBC, maybe it's worth having two flavours of SQL Delight: SQL Delight and SQL Delight Async which can then more easily cater for async drivers. On the async side, you have R2DBC which supports Project Reactor and RxJava styles covering Cloud Spanner, wrapping Jasync for MySQL and PostgreSQL, native drivers for h2, MariaDB, MSSQL as well as its own drivers for MySQL and PostgreSQL. I'm assuming an async SQL Delight would be littered with suspends everywhere which would not be ideal for an SQL Delight running on JDBC |
Currently SQL Delight is using JDBC or other blocking drivers
Jasync has async MySQL / PostgreSQL drivers which although it's using annoying Joda time, works great otherwise
(there is a ticket there somewhere to replace Joda Time with Java Time)
Converting Joda Time is not difficult either
Jasync returns a Future and can easily be converted to a Coroutine allowing non-blocking queries
The text was updated successfully, but these errors were encountered: