Skip to content

fix(macros): added SQLX_SQLITE_REGISTER_REGEXP environment variable - #4313

Closed
XVanilor wants to merge 1 commit into
transact-rs:mainfrom
XVanilor:fix/vanilor/add-sqlite-regexp-macros-support
Closed

fix(macros): added SQLX_SQLITE_REGISTER_REGEXP environment variable#4313
XVanilor wants to merge 1 commit into
transact-rs:mainfrom
XVanilor:fix/vanilor/add-sqlite-regexp-macros-support

Conversation

@XVanilor

Copy link
Copy Markdown

Does your PR solve an issue?

Fixes #3070

As it's my first ever contribution to an open-source project, please tell me everything I've got wrong or if I can improve the PR to be clearer.

This intend to allow sqlite regexp function to be used with macros, it extends an already-supported feature.

The change also allows by-design the use of the new SQLX_SQLITE_REGISTER_REGEXP with sqlx-cli prepare command.

I'm waiting a run of CI to make sure that the new test does not fail (ie if the new SQLX_SQLITE_REGISTER_REGEXP needs to be added to the existing environment workflow).

Is this a breaking change?

No.

- fix issue transact-rs#3070
- allows sqlx-cli prepare to work with sqlite regexp
@XVanilor
XVanilor force-pushed the fix/vanilor/add-sqlite-regexp-macros-support branch from ec6c531 to 9ddf6a4 Compare June 17, 2026 19:25
@abonander

Copy link
Copy Markdown
Collaborator

This should be added as a field in sqlx.toml instead of an environment variable:

pub struct SqliteConfig {

pub(crate) fn apply_driver_config(
mut self,
config: &config::drivers::SqliteConfig,
) -> crate::Result<Self> {
#[cfg(feature = "load-extension")]
for extension in &config.unsafe_load_extensions {
// SAFETY: the documentation warns the user about loading extensions
match extension {
config::drivers::SqliteExtension::Path(path) => {
self = unsafe { self.extension(path.clone()) }
}
config::drivers::SqliteExtension::PathWithEntrypoint { path, entrypoint } => {
self =
unsafe { self.extension_with_entrypoint(path.clone(), entrypoint.clone()) }
}
}
}
#[cfg(not(feature = "load-extension"))]
if !config.unsafe_load_extensions.is_empty() {
return Err(sqlx_core::Error::Configuration(
format!(
"sqlx.toml specifies `drivers.sqlite.unsafe-load-extensions = {:?}` \
but extension loading is not enabled; \
enable the `sqlite-load-extension` feature of SQLx to use SQLite extensions",
config.unsafe_load_extensions,
)
.into(),
));
}
Ok(self)
}

Closing because I'm trying to pare down the backlog but please feel free to open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SQLite] REGEXP feature does not work with macros

2 participants