diesel-rs / diesel

A safe, extensible ORM and Query Builder for Rust
https://diesel.rs
Apache License 2.0
12.48k stars 1.04k forks source link

Loading a sqlite3 extension? #1867

Open tyrylu opened 5 years ago

tyrylu commented 5 years ago

Hello. Did i miss something or is it really not possible (diesel 1.3) to load a sqlite3 extension? I discovered this when trying to make a spatialite initialization sequence work, but without the extension it obviously can not work. Doing a pull request exposing the APIs on SqliteConnection would probably not be as hard, but how would you go about allowing extension loading in migrations (e. g. how of a bad idea would it be to allow extension loading by default)?

weiznich commented 5 years ago

What's wrong with sql_query("SELECT load_extension('libspatialite-2.so');").execute(&connection)? as part of your startup sequence?

tyrylu commented 5 years ago

This is unfortunately not enough, because at least for the windows builds it is necessary to call the enable_load_extension c function which has no sql function counterpart, without it you end up with an unauthorized error (tried a few hours ago with the bundled 3.24 version in sqlite3-sys).

alamminsalo commented 5 years ago

This would be great feature, currently I have to use a separate sqlite lib to load and query with extensions.