{"record":{"id":"b7622b1eedac9028","repo":"diesel-rs/diesel","slug":"sqlite-s-documentation-state-that-this-case-i","errorCode":null,"errorMessage":"Sqlite's documentation state that this case ({}) is not reachable. If you ever see this error message please open an issue at https://github.com/diesel-rs/diesel.","messagePattern":"Sqlite's documentation state that this case \\((.+?)\\) is not reachable\\. If you ever see this error message please open an issue at https://github\\.com/diesel-rs/diesel\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"diesel/src/sqlite/connection/sqlite_value.rs","lineNumber":411,"sourceCode":"        unsafe { value_type_of(self.value) }\n    }\n}\n\n/// Reads a value's type, which SQLite reports as SQL `NULL` for a failed conversion.\n///\n/// # Safety\n///\n/// `value` must point to a live `sqlite3_value`.\nunsafe fn value_type_of(value: NonNull<ffi::sqlite3_value>) -> Option<SqliteType> {\n    // SAFETY: the caller guarantees a live value, which this call only inspects.\n    let tpe = unsafe { ffi::sqlite3_value_type(value.as_ptr()) };\n    match tpe {\n        ffi::SQLITE_TEXT => Some(SqliteType::Text),\n        ffi::SQLITE_INTEGER => Some(SqliteType::Long),\n        ffi::SQLITE_FLOAT => Some(SqliteType::Double),\n        ffi::SQLITE_BLOB => Some(SqliteType::Binary),\n        ffi::SQLITE_NULL => None,\n        _ => unreachable!(\n            \"Sqlite's documentation state that this case ({}) is not reachable. \\\n             If you ever see this error message please open an issue at \\\n             https://github.com/diesel-rs/diesel.\",\n            tpe\n        ),\n    }\n}\n\nimpl OwnedSqliteValue {\n    /// Copies a value out of a statement or a function argument.\n    ///\n    /// `Ok(None)` is SQL `NULL`. A failed allocation is an error instead, as reporting\n    /// it as `NULL` would hand out a wrong value.\n    pub(super) fn copy_from_ptr(\n        ptr: NonNull<ffi::sqlite3_value>,\n    ) -> QueryResult<Option<OwnedSqliteValue>> {\n        // SAFETY: `ptr` points to a live `sqlite3_value` owned by the statement or\n        // callback that outlives this call, and reading its type only inspects it.","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel/src/sqlite/connection/sqlite_value.rs#L393-L429","documentation":"`value_type_of` maps libsqlite3 column type codes (SQLITE_TEXT/INTEGER/FLOAT/BLOB/NULL) to diesel's `SqliteType`. SQLite documents only those five return values for `sqlite3_column_type`, so any other code triggers `unreachable!`. Seeing it means either an out-of-spec SQLite build/FFI mismatch or a diesel bug.","triggerScenarios":"A `sqlite3_column_type` call returning a code outside {1,2,3,4,5} while constructing `SqliteValue` via `new`, `from_owned_row`, `from_function_row`, or `value_type` — e.g. an FFI mismatch where codes are misinterpreted.","commonSituations":"Mismatched libsqlite3/linking (bundled vs system SQLite with ABI differences); exotic SQLite forks returning custom codes; corrupted memory/UB from unsound FFI usage; very old diesel against a much newer SQLite.","solutions":["Print/report the unexpected type code in the message and check which value it is.","Use diesel's `bundled` sqlite feature (`libsqlite3-sys` bundled) so SQLite versions match what diesel expects.","Upgrade diesel and libsqlite3-sys to latest; check for duplicate SQLite libraries linked into the binary.","Open an issue at https://github.com/diesel-rs/diesel with the type code if it persists."],"exampleFix":"// before (Cargo.toml)\ndiesel = { version = \"2\", features = [\"sqlite\"] }\n// after\ndiesel = { version = \"2\", features = [\"sqlite\", \"returning_clauses_for_sqlite_3_35\"] }\nlibsqlite3-sys = { version = \"*\", features = [\"bundled\"] } # via diesel's bundled feature","handlingStrategy":"validation","validationCode":"// ensure a single, compatible SQLite is linked\n// Cargo.toml: rely on diesel's bundled sqlite so libsqlite3-sys versions match\ndiesel = { version = \"2\", features = [\"sqlite\"] }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use diesel's bundled SQLite feature; avoid mixing system and bundled libsqlite3.","Keep diesel and libsqlite3-sys versions in sync.","Treat any occurrence as a bug: capture the reported type code and report it."],"tags":["sqlite","ffi","internal-bug","unreachable"],"backgroundTag":"internal-invariant-violation","analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}