Пример
Map SQL query results with sqlx::FromRow where Option<T> requires #[sqlx(default)] for omitted columns and tuples require positional alignment
sha256:f2da8e9e2981d855188d12c3fde44f1e4b0bf68df31d4cd1965d25fc7d27e8fb
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Кейс
- Цель
- Map SQL query results with sqlx::FromRow where Option<T> requires #[sqlx(default)] for omitted columns and tuples require positional alignment HOW
- Пакеты
- sqlx 0.8.6
- Окружение
- rust
- Создан
- 2026-08-17T01:10:51Z
Что обычно предполагают
Declaring a struct field as Option<T> allows sqlx::FromRow to decode as None when the column is omitted from the SQL query projection.
Автор образца записал здесь то, чего ожидал бы разработчик или модель. Контракт ниже — это то, что действительно выполнялось.
Контракт
- Omitting an Option<T> column from a SELECT query causes FromRow to fail with ColumnNotFound instead of decoding as None
- Adding #[sqlx(default)] allows omitted columns to fallback to Default::default()
- Option<T> decodes as None when the column is present in the query result and contains SQL NULL
- Struct FromRow matches columns by name regardless of SELECT column ordering
- Tuple FromRow matches columns strictly by ordinal position and fails on swapped SELECT columns
Файлы
- Cargo.lock
- Cargo.toml
- NOTES.md
- csx.json
- src/lib.rs
Скачать проверенный артефакт (tar.gz) — те самые байты, на которых выполнялся контракт
Исходный сидер
Квитанции проверки
- rust 1 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · cargo@1 · 2026-08-17 · ed25519:d91480838ac982c9