sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Allow using sqlite extensions during comptime verification

Open Suya1671 opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. I'm trying to use the uuid extension for the uuid_blob() function in sqlite. However, this errors out comptime verification since it doesn't load any extensions by default, nor is there a way to enable/add extensions at compile time.

Describe the solution you'd like Some way to configure loading extensions during compile-time query checks. One way is to add query params to the DATABASE_URL (and also load the extensions at runtime as well), which would look something like sqlite://database.db?extension=uuid&extension=vsv

Describe alternatives you've considered Compile sqlite with the extensions enabled by default

Additional context seems that there were plans to do something like this in https://github.com/launchbadge/sqlx/issues/1460#issuecomment-929783568

Suya1671 avatar Jul 05 '24 09:07 Suya1671

This can be built on top of #3383 when it's merged. Something like:

[drivers.sqlite]
load-extensions = ["uuid", "vsv"]

abonander avatar Sep 20 '24 06:09 abonander

That would be great! Being unable to use SQLite extensions in migrations just became a big problem for me. When using Spatialite, you have to be able to call Spatialite functions to create and delete spatial tables and build spatial indexes.

djarb avatar Jan 15 '25 13:01 djarb

That would be great! Being unable to use SQLite extensions in migrations just became a big problem for me. When using Spatialite, you have to be able to call Spatialite functions to create and delete spatial tables and build spatial indexes.

I am currently facing the same issue right now, have you a work-around?

areleu avatar Jan 27 '25 15:01 areleu

I found a partial workaround for the trouble with the migrations, but if you get past that you hit a hard stop with the compile-time checking. A way to tell SQLx to load extensions across the board is the correct solution.

My current plan is to devote time this week to implementing https://github.com/launchbadge/sqlx/issues/3330#issuecomment-2362932640 and submitting a pull request.

djarb avatar Jan 27 '25 16:01 djarb