Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Avoid building a host SQLite driver for SQLx macros (#47084)

Ahmed Ibrahim3627bb91b2f1
diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock
index 641848377e..d8bd8b4de2 100644
--- a/codex-rs/Cargo.lock
+++ b/codex-rs/Cargo.lock
@@ -4677,6 +4677,8 @@ dependencies = [
"serde",
"serde_json",
"sqlx",
+ "sqlx-macros",
+ "sqlx-sqlite",
"strum 0.27.2",
"tokio",
"tracing",
@@ -4766,6 +4768,7 @@ dependencies = [
"serde",
"serde_json",
"sqlx",
+ "sqlx-macros",
"tempfile",
"thiserror 2.0.18",
"tokio",
@@ -14695,7 +14698,6 @@ dependencies = [
"sqlx-postgres",
"sqlx-sqlite",
"syn 2.0.117",
- "thiserror 2.0.18",
"tokio",
"url",
]
diff --git a/codex-rs/Cargo.toml b/codex-rs/Cargo.toml
index 2f0c3a5ecd..4512261e77 100644
--- a/codex-rs/Cargo.toml
+++ b/codex-rs/Cargo.toml
@@ -468,11 +468,10 @@ symphonia = { version = "0.6.0", default-features = false, features = [
"wav",
] }
socket2 = "0.6.1"
-# When bumping sqlx, audit the SQLite constructor deny list in clippy.toml.
-sqlx = { version = "0.9.0", default-features = false, features = [
+# Keep SQLx versions in sync; when bumping, audit the SQLite constructor deny list in clippy.toml.
+sqlx = { version = "=0.9.0", default-features = false, features = [
"chrono",
"json",
- "macros",
"migrate",
"runtime-tokio",
"tls-rustls",
@@ -480,6 +479,10 @@ sqlx = { version = "0.9.0", default-features = false, features = [
"time",
"uuid",
] }
+# Derives and migration embedding do not need query macros or a host SQLite driver.
+sqlx-macros = { version = "=0.9.0", default-features = false, features = ["derive", "migrate"] }
+# Preserve the target driver's query-description support without building it on the host.
+sqlx-sqlite = { version = "=0.9.0", default-features = false, features = ["offline"] }
starlark = { version = "0.14.2", default-features = false }
strum = "0.27.2"
strum_macros = "0.28.0"
diff --git a/codex-rs/state/Cargo.toml b/codex-rs/state/Cargo.toml
index 0d781fbff2..c6c2215fb4 100644
--- a/codex-rs/state/Cargo.toml
+++ b/codex-rs/state/Cargo.toml
@@ -15,6 +15,8 @@ log = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sqlx = { workspace = true }
+sqlx-macros = { workspace = true }
+sqlx-sqlite = { workspace = true }
strum = { workspace = true, features = ["derive"] }
tokio = { workspace = true, features = ["fs", "io-util", "macros", "rt-multi-thread", "sync", "time"] }
tracing = { workspace = true }
diff --git a/codex-rs/state/src/migrations.rs b/codex-rs/state/src/migrations.rs
index 07d36588f0..efbb76cc09 100644
--- a/codex-rs/state/src/migrations.rs
+++ b/codex-rs/state/src/migrations.rs
@@ -1,14 +1,15 @@
use std::borrow::Cow;
-use sqlx::SqlitePool;
use sqlx::migrate::Migrator;
+use sqlx_sqlite::SqlitePool;
-pub(crate) static STATE_MIGRATOR: Migrator = sqlx::migrate!("./migrations");
-pub(crate) static LOGS_MIGRATOR: Migrator = sqlx::migrate!("./logs_migrations");
-pub(crate) static GOALS_MIGRATOR: Migrator = sqlx::migrate!("./goals_migrations");
-pub(crate) static MEMORIES_MIGRATOR: Migrator = sqlx::migrate!("./memory_migrations");
-pub(crate) static QUEUE_MIGRATOR: Migrator = sqlx::migrate!("./queue_migrations");
-pub(crate) static THREAD_HISTORY_MIGRATOR: Migrator = sqlx::migrate!("./thread_history_migrations");
+pub(crate) static STATE_MIGRATOR: Migrator = sqlx_macros::migrate!("./migrations");
+pub(crate) static LOGS_MIGRATOR: Migrator = sqlx_macros::migrate!("./logs_migrations");
+pub(crate) static GOALS_MIGRATOR: Migrator = sqlx_macros::migrate!("./goals_migrations");
+pub(crate) static MEMORIES_MIGRATOR: Migrator = sqlx_macros::migrate!("./memory_migrations");
+pub(crate) static QUEUE_MIGRATOR: Migrator = sqlx_macros::migrate!("./queue_migrations");
+pub(crate) static THREAD_HISTORY_MIGRATOR: Migrator =
+ sqlx_macros::migrate!("./thread_history_migrations");
/// Allow an older Codex binary to open a database that has already been
/// migrated by a newer binary running in parallel.
diff --git a/codex-rs/state/src/model/log.rs b/codex-rs/state/src/model/log.rs
index 43685dfdd8..cc46d0b1ca 100644
--- a/codex-rs/state/src/model/log.rs
+++ b/codex-rs/state/src/model/log.rs
@@ -1,5 +1,5 @@
use serde::Serialize;
-use sqlx::FromRow;
+use sqlx_macros::FromRow;
#[derive(Clone, Debug, Serialize)]
pub struct LogEntry {
diff --git a/codex-rs/state/src/runtime/logs.rs b/codex-rs/state/src/runtime/logs.rs
index d2525480c7..0cdc91124c 100644
--- a/codex-rs/state/src/runtime/logs.rs
+++ b/codex-rs/state/src/runtime/logs.rs
@@ -441,7 +441,7 @@ WHERE cumulative_estimated_bytes <=
}
}
-#[derive(sqlx::FromRow)]
+#[derive(sqlx_macros::FromRow)]
struct FeedbackLogRow {
ts: i64,
ts_nanos: i64,
diff --git a/codex-rs/thread-store/Cargo.toml b/codex-rs/thread-store/Cargo.toml
index b0d2b15568..31e16dd72a 100644
--- a/codex-rs/thread-store/Cargo.toml
+++ b/codex-rs/thread-store/Cargo.toml
@@ -30,6 +30,7 @@ pulldown-cmark = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sqlx = { workspace = true }
+sqlx-macros = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
diff --git a/codex-rs/thread-store/src/local/thread_history/read.rs b/codex-rs/thread-store/src/local/thread_history/read.rs
index b2e3e6713b..7dd06c74cd 100644
--- a/codex-rs/thread-store/src/local/thread_history/read.rs
+++ b/codex-rs/thread-store/src/local/thread_history/read.rs
@@ -62,7 +62,7 @@ pub(super) struct StoredTurnRow {
pub summary_items: Vec<StoredThreadItem>,
}
-#[derive(sqlx::FromRow)]
+#[derive(sqlx_macros::FromRow)]
pub(super) struct StoredSummaryColumns {
summary_first_user_turn_id: Option<String>,
summary_first_user_item_id: Option<String>,