Replies: 1 comment
-
|
Thanks for writing this proposal. It's very reasonable to abstract this way. In the end we should end up with a similar setup like for the I'm happy to review PR's for both changes, although I currently don't have the capacity to implement it on my own. Finally as for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Backend
SQLite
What do you want to add to diesel?
I'm interested in building SQLite queries with Diesel and then running them against a custom connection implementation. My main motivation is that I want to build auto-updating reactive queries that automatically re-run whenever a table mentioned in a
SELECTchanges. But this would also be helpful to use Diesel with SQLite-compatible engines like libsql or Turso.So in the end, I only really need the query-building part of Diesel and I'd write my own connections to actually run statements and to track updates asynchronously.
Getting the SQL text out of an
QueryFragment<Sqlite>is easy enough sinceSqliteQueryBuilderis public and exposes the SQL text after visiting an AST.However, it looks like it's impossible to extract parameters:
SqliteBindCollectoris private, and I can only construct it through<<Sqlite as Backend>::BindCollector<'_> as Default>::default(). But there is seemingly no way to get bound values out of the collector outside of thedieselcrate.Backendwith aBindCollectorthat delegates toSqliteas much as possible. But some fragments are only implemented for theSqlitebackend and I'd have to replicate that logic.The bind collector for SQLite being async creates a strong coupling between the query builder and the connection, making them impossible to use independently. So my feature request is to expose an API allowing users to inspect bound parameter values generated by the SQL dialect.
Implementation notes
Ideally, I would like
InternalSqliteBindValueandSqliteBindCollectorto be public.If that is not feasible, perhaps there could be an API to obtain bound values in general.
AstPass::collect_debug_binds_passis quite close to that already, since I can do this and then wrap any query fragment in that struct to callcollect_bindson it:But the values I get are
&dyn Debugwhen I would probably need them to beToSqlto inspect them. But having a similar ast pass configuration to get mapped values would be helpful.Additional details
No response
Checklist
Beta Was this translation helpful? Give feedback.
All reactions