From 7920dbc5ffcdeecdff407f5105370d4d40586ba8 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Tue, 15 Dec 2015 14:41:54 -0500 Subject: [PATCH] Only check for SQLITE_CONSTRAINT_NOTNULL on new enough versions of SQLite. --- src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 564aca5..7ca67e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1358,7 +1358,16 @@ mod test { assert!(result.is_err()); match result.unwrap_err() { - Error::SqliteFailure(err, _) => assert_eq!(err.extended_code, ffi::SQLITE_CONSTRAINT_NOTNULL), + Error::SqliteFailure(err, _) => { + assert_eq!(err.code, ffi::ErrorCode::ConstraintViolation); + + // extended error codes for constraints were added in SQLite 3.7.16; if we're + // running on a version at least that new, check for the extended code + let version = unsafe { ffi::sqlite3_libversion_number() }; + if version >= 3007016 { + assert_eq!(err.extended_code, ffi::SQLITE_CONSTRAINT_NOTNULL) + } + }, err => panic!("Unexpected error {}", err), } }