From 50d379b564da9586ea0f93e3d80658acf3464159 Mon Sep 17 00:00:00 2001 From: gwenn Date: Tue, 27 Mar 2018 20:07:46 +0200 Subject: [PATCH 1/2] Make Statement::column_index case insensitive Fix #330 --- src/statement.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/statement.rs b/src/statement.rs index 2674c32..09c3bc3 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -45,7 +45,7 @@ impl<'conn> Statement<'conn> { let bytes = name.as_bytes(); let n = self.column_count(); for i in 0..n { - if bytes == self.stmt.column_name(i).to_bytes() { + if bytes.eq_ignore_ascii_case(self.stmt.column_name(i).to_bytes()) { return Ok(i); } } @@ -785,4 +785,30 @@ mod test { let y: Result = stmt.query_row(&[&1i32], |r| r.get(0)); assert_eq!(3i64, y.unwrap()); } + + #[test] + fn test_query_by_column_name() { + let db = Connection::open_in_memory().unwrap(); + let sql = "BEGIN; + CREATE TABLE foo(x INTEGER, y INTEGER); + INSERT INTO foo VALUES(1, 3); + END;"; + db.execute_batch(sql).unwrap(); + let mut stmt = db.prepare("SELECT y FROM foo").unwrap(); + let y: Result = stmt.query_row(&[], |r| r.get("y")); + assert_eq!(3i64, y.unwrap()); + } + + #[test] + fn test_query_by_column_name_ignore_case() { + let db = Connection::open_in_memory().unwrap(); + let sql = "BEGIN; + CREATE TABLE foo(x INTEGER, y INTEGER); + INSERT INTO foo VALUES(1, 3); + END;"; + db.execute_batch(sql).unwrap(); + let mut stmt = db.prepare("SELECT y as Y FROM foo").unwrap(); + let y: Result = stmt.query_row(&[], |r| r.get("y")); + assert_eq!(3i64, y.unwrap()); + } } From 7f193c03f1131a32b76d304cc8286d33181ea09c Mon Sep 17 00:00:00 2001 From: gwenn Date: Tue, 27 Mar 2018 20:40:41 +0200 Subject: [PATCH 2/2] Upgrade stable version used by appveyor --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3b87004..155f6e7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,8 @@ environment: matrix: - - TARGET: 1.21.0-x86_64-pc-windows-gnu + - TARGET: 1.24.1-x86_64-pc-windows-gnu MSYS2_BITS: 64 - - TARGET: 1.21.0-x86_64-pc-windows-msvc + - TARGET: 1.24.1-x86_64-pc-windows-msvc VCPKG_DEFAULT_TRIPLET: x64-windows VCPKGRS_DYNAMIC: 1 - TARGET: nightly-x86_64-pc-windows-msvc