Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tracing = { version = "0.1.41", default-features = false, features = ["std", "re
uuid = { version = "1.11.0", features = ["v4"] }

# SQLx for types and queries (time feature enables datetime type decoding)
sqlx = { version = "0.8.6", features = ["sqlite", "json", "time", "runtime-tokio"] }
sqlx = { version = "0.9.0-alpha.1", features = ["sqlite", "json", "time", "runtime-tokio"] }

# Connection manager
sqlx-sqlite-conn-mgr = { path = "crates/sqlx-sqlite-conn-mgr" }
Expand Down
2 changes: 1 addition & 1 deletion crates/sqlx-sqlite-conn-mgr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords = ["sqlite", "sqlx", "database", "connection-pool", "async"]
categories = ["database", "asynchronous"]

[dependencies]
sqlx = { version = "0.8.6", features = ["runtime-tokio", "sqlite", "migrate"] }
sqlx = { version = "0.9.0-alpha.1", features = ["runtime-tokio", "sqlite", "migrate"] }
thiserror = "2.0.17"
tokio = { version = "1.49.0", features = ["full"] }
tracing = { version = "0.1.44", default-features = false, features = ["std", "release_max_level_off"] }
Expand Down
16 changes: 12 additions & 4 deletions crates/sqlx-sqlite-conn-mgr/src/attached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ impl AttachedReadConnection {
pub async fn detach_all(mut self) -> Result<()> {
for schema_name in &self.schema_names {
let detach_sql = format!("DETACH DATABASE \"{}\"", schema_name);
sqlx::query(&detach_sql).execute(&mut *self.conn).await?;
sqlx::query(sqlx::AssertSqlSafe(detach_sql))
.execute(&mut *self.conn)
.await?;
}
Ok(())
}
Expand Down Expand Up @@ -141,7 +143,9 @@ impl AttachedWriteGuard {
pub async fn detach_all(mut self) -> Result<()> {
for schema_name in &self.schema_names {
let detach_sql = format!("DETACH DATABASE \"{}\"", schema_name);
sqlx::query(&detach_sql).execute(&mut *self.writer).await?;
sqlx::query(sqlx::AssertSqlSafe(detach_sql))
.execute(&mut *self.writer)
.await?;
}
Ok(())
}
Expand Down Expand Up @@ -256,7 +260,9 @@ pub async fn acquire_reader_with_attached(
"ATTACH DATABASE '{}' AS \"{}\"",
escaped_path, spec.schema_name
);
sqlx::query(&attach_sql).execute(&mut *conn).await?;
sqlx::query(sqlx::AssertSqlSafe(attach_sql))
.execute(&mut *conn)
.await?;

schema_names.push(spec.schema_name);
}
Expand Down Expand Up @@ -356,7 +362,9 @@ pub async fn acquire_writer_with_attached(
"ATTACH DATABASE '{}' AS \"{}\"",
escaped_path, spec.schema_name
);
sqlx::query(&attach_sql).execute(&mut *writer).await?;
sqlx::query(sqlx::AssertSqlSafe(attach_sql))
.execute(&mut *writer)
.await?;

schema_names.push(spec.schema_name);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/sqlx-sqlite-observer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ thiserror = "2.0.17"
tracing = { version = "0.1.44", default-features = false, features = ["std", "release_max_level_off"] }
parking_lot = "0.12.3"
regex = "1.12.3"
sqlx = { version = "0.8.6", features = ["sqlite", "runtime-tokio"], default-features = false }
sqlx = { version = "0.9.0-alpha.1", features = ["sqlite", "runtime-tokio"], default-features = false }
# Required for preupdate_hook - SQLite must be compiled with SQLITE_ENABLE_PREUPDATE_HOOK
libsqlite3-sys = { version = "0.30.1", features = ["preupdate_hook"] }
libsqlite3-sys = { version = "0.35.0", features = ["preupdate_hook"] }
sqlx-sqlite-conn-mgr = { path = "../sqlx-sqlite-conn-mgr", version = "0.8.7", optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/sqlx-sqlite-toolkit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ observer = ["dep:sqlx-sqlite-observer"]
[dependencies]
sqlx-sqlite-conn-mgr = { path = "../sqlx-sqlite-conn-mgr" }
sqlx-sqlite-observer = { path = "../sqlx-sqlite-observer", features = ["conn-mgr"], optional = true }
sqlx = { version = "0.8.6", features = ["sqlite", "json", "time", "runtime-tokio"] }
sqlx = { version = "0.9.0-alpha.1", features = ["sqlite", "json", "time", "runtime-tokio"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "2.0"
Expand Down
16 changes: 8 additions & 8 deletions crates/sqlx-sqlite-toolkit/src/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl FetchAllBuilder {
if self.attached.is_empty() {
// No attached databases - use regular read pool
let pool = self.db.read_pool()?;
let mut q = sqlx::query(&self.query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(self.query));
for value in self.values {
q = bind_value(q, value);
}
Expand All @@ -56,7 +56,7 @@ impl FetchAllBuilder {
let mut conn =
sqlx_sqlite_conn_mgr::acquire_reader_with_attached(&self.db, self.attached).await?;

let mut q = sqlx::query(&self.query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(self.query));
for value in self.values {
q = bind_value(q, value);
}
Expand Down Expand Up @@ -112,7 +112,7 @@ impl FetchOneBuilder {
let rows = if self.attached.is_empty() {
// No attached databases - use regular read pool
let pool = self.db.read_pool()?;
let mut q = sqlx::query(&self.query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(self.query));
for value in self.values {
q = bind_value(q, value);
}
Expand All @@ -122,7 +122,7 @@ impl FetchOneBuilder {
let mut conn =
sqlx_sqlite_conn_mgr::acquire_reader_with_attached(&self.db, self.attached).await?;

let mut q = sqlx::query(&self.query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(self.query));
for value in self.values {
q = bind_value(q, value);
}
Expand Down Expand Up @@ -259,7 +259,7 @@ impl FetchPageBuilder {
// Execute query
let rows = if self.attached.is_empty() {
let pool = self.db.read_pool()?;
let mut q = sqlx::query(&sql);
let mut q = sqlx::query(sqlx::AssertSqlSafe(sql));
for value in all_values {
q = bind_value(q, value);
}
Expand All @@ -268,7 +268,7 @@ impl FetchPageBuilder {
let mut conn =
sqlx_sqlite_conn_mgr::acquire_reader_with_attached(&self.db, self.attached).await?;

let mut q = sqlx::query(&sql);
let mut q = sqlx::query(sqlx::AssertSqlSafe(sql));
for value in all_values {
q = bind_value(q, value);
}
Expand Down Expand Up @@ -365,7 +365,7 @@ impl ExecuteBuilder {
if self.attached.is_empty() {
// No attached databases - use wrapper's writer (routes through observer when in use)
let mut writer = self.db.acquire_writer().await?;
let mut q = sqlx::query(&self.query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(self.query));
for value in self.values {
q = bind_value(q, value);
}
Expand All @@ -380,7 +380,7 @@ impl ExecuteBuilder {
sqlx_sqlite_conn_mgr::acquire_writer_with_attached(self.db.inner(), self.attached)
.await?;

let mut q = sqlx::query(&self.query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(self.query));
for value in self.values {
q = bind_value(q, value);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/sqlx-sqlite-toolkit/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl TransactionWriter {
/// Execute a query on either writer type
pub async fn execute_query<'a>(
&mut self,
query: sqlx::query::Query<'a, sqlx::Sqlite, sqlx::sqlite::SqliteArguments<'a>>,
query: sqlx::query::Query<'a, sqlx::Sqlite, sqlx::sqlite::SqliteArguments>,
) -> Result<sqlx::sqlite::SqliteQueryResult> {
match self {
Self::Regular(w) => query.execute(&mut **w).await.map_err(Into::into),
Expand All @@ -45,7 +45,7 @@ impl TransactionWriter {
/// Fetch all rows from either writer type
pub async fn fetch_all<'a>(
&mut self,
query: sqlx::query::Query<'a, sqlx::Sqlite, sqlx::sqlite::SqliteArguments<'a>>,
query: sqlx::query::Query<'a, sqlx::Sqlite, sqlx::sqlite::SqliteArguments>,
) -> Result<Vec<sqlx::sqlite::SqliteRow>> {
match self {
Self::Regular(w) => query.fetch_all(&mut **w).await.map_err(Into::into),
Expand Down Expand Up @@ -149,7 +149,7 @@ impl ActiveInterruptibleTransaction {
query: String,
values: Vec<JsonValue>,
) -> Result<Vec<IndexMap<String, JsonValue>>> {
let mut q = sqlx::query(&query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(query));
for value in values {
q = crate::wrapper::bind_value(q, value);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ impl ActiveInterruptibleTransaction {
let writer = self.writer_mut()?;
for statement in statements {
let statement = statement.into();
let mut q = sqlx::query(&statement.query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(statement.query));
for value in statement.values {
q = crate::wrapper::bind_value(q, value);
}
Expand Down
6 changes: 3 additions & 3 deletions crates/sqlx-sqlite-toolkit/src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ impl TransactionExecutionBuilder {
let exec_result = async {
let mut results = Vec::new();
for (query, values) in self.statements {
let mut q = sqlx::query(&query);
let mut q = sqlx::query(sqlx::AssertSqlSafe(query));
for value in values {
q = bind_value(q, value);
}
Expand Down Expand Up @@ -626,9 +626,9 @@ impl std::future::IntoFuture for TransactionExecutionBuilder {

/// Helper function to bind a JSON value to a SQLx query
pub fn bind_value<'a>(
query: sqlx::query::Query<'a, sqlx::Sqlite, sqlx::sqlite::SqliteArguments<'a>>,
query: sqlx::query::Query<'a, sqlx::Sqlite, sqlx::sqlite::SqliteArguments>,
value: JsonValue,
) -> sqlx::query::Query<'a, sqlx::Sqlite, sqlx::sqlite::SqliteArguments<'a>> {
) -> sqlx::query::Query<'a, sqlx::Sqlite, sqlx::sqlite::SqliteArguments> {
if value.is_null() {
query.bind(None::<JsonValue>)
} else if value.is_string() {
Expand Down