-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Access to connection handle #430
Comments
SQLite calls it a database connection handle so I'd probably expect a method named |
Thanks for the tip. So perhaps the correct approach is to extend |
We're actually discussing the option to configure an on-connect callback to |
Yes, that sounds like the right idea. |
While the method to get the raw handle is being added in #438, it also sounds like having a way to safely introduce new collations would be a good feature-add for the SQLite API. Maybe something like: impl SqliteConnection {
pub fn add_collation(&mut self, name: &str, collation: impl Fn(&str, &str) -> Ordering + Send + Sync + 'static) { ... }
} |
The implementation would be simpler but the interface less flexible if the callback was defined as |
I'll give this a shot. The feature already exists in It would still require #263 to ensure that connections are configured consistently. |
We probably don't want to pull in Let's not directly copy it though. Now I'm thinking that I would like to somehow make this work with |
It looks like it invokes the callback once for any collation that it can't find and emit error if it still can't find the collation after invoking the callback: https://github.com/sqlite/sqlite/blob/42a630b1daf1df13850095251cc73be84dbdeac8/src/callback.c#L217-L231 This means we can definitely use |
I'm not clear on the utility of |
I'm thinking we could have both relatively easily: impl SqliteConnection {
pub fn add_collation(&mut self, ...) -> &mut Self { ... }
pub fn install_collations_lazily(&mut self) -> &mut Self { ... }
} and then if Unless maybe people would want to mix both eagerly and lazily created collations? This sounds like some quite niche optimizations though. I think for an MVP all we need is I also imagine part of the utility in lazily creating collations would be to actually run user code when they need to be created, so that may warrant a different interface entirely. |
Personally I'm of the opinion this stuff should be exposed fairly directly on |
It would be useful to be able to get the underlying
sqlite3*
handle so that the database can be further configured, or to be able to customize the creation and configuration of the connection using the handle.For instance, I would like to be able to call
sqlite3_create_collation_v2
to set up a collating sequence using theunicase
crate.The text was updated successfully, but these errors were encountered: