mirror of
https://github.com/isar/rusqlite.git
synced 2025-09-16 20:52:19 +08:00
Attempt to enable extended result codes for all connections
This commit is contained in:
16
src/lib.rs
16
src/lib.rs
@@ -616,6 +616,10 @@ impl InnerConnection {
|
|||||||
ffi::sqlite3_close(db);
|
ffi::sqlite3_close(db);
|
||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attempt to turn on extended results code; don't fail if we can't.
|
||||||
|
ffi::sqlite3_extended_result_codes(db, 1);
|
||||||
|
|
||||||
Ok(InnerConnection { db: db })
|
Ok(InnerConnection { db: db })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1421,6 +1425,18 @@ mod test {
|
|||||||
assert!(format!("{:?}", stmt).contains(query));
|
assert!(format!("{:?}", stmt).contains(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_notnull_constraint_error() {
|
||||||
|
let db = checked_memory_handle();
|
||||||
|
db.execute_batch("CREATE TABLE foo(x NOT NULL)").unwrap();
|
||||||
|
|
||||||
|
let result = db.execute("INSERT INTO foo (x) VALUES (NULL)", &[]);
|
||||||
|
assert!(result.is_err());
|
||||||
|
|
||||||
|
let err = result.err().unwrap();
|
||||||
|
assert_eq!(err.code, ffi::SQLITE_CONSTRAINT_NOTNULL);
|
||||||
|
}
|
||||||
|
|
||||||
mod query_and_then_tests {
|
mod query_and_then_tests {
|
||||||
extern crate libsqlite3_sys as ffi;
|
extern crate libsqlite3_sys as ffi;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
Reference in New Issue
Block a user