diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 22ffacc28..06c18a0cd 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -408,7 +408,7 @@ pub struct BTreeCursor { /// Store whether the Cursor is in a valid state. Meaning if it is pointing to a valid cell index or not valid_state: CursorValidState, /// Colations for Index Btree constraint checks - /// Contains the Collation Seq for the whole Table + /// Contains the Collation Seq for the whole Index /// This Vec should be empty for Table Btree collations: Vec, } diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index a05a9f731..c3e7f328c 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -940,10 +940,17 @@ pub fn op_open_read( .get_table(&index.table_name) .map_or(None, |table| table.btree()); let collations = table.map_or(Vec::new(), |table| { - table - .column_collations() - .into_iter() - .map(|c| c.unwrap_or_default()) + index + .columns + .iter() + .map(|c| { + table + .columns + .get(c.pos_in_table) + .unwrap() + .collation + .unwrap_or_default() + }) .collect() }); let cursor = BTreeCursor::new_index( @@ -4245,10 +4252,17 @@ pub fn op_open_write( .get_table(&index.table_name) .map_or(None, |table| table.btree()); let collations = table.map_or(Vec::new(), |table| { - table - .column_collations() - .into_iter() - .map(|c| c.unwrap_or_default()) + index + .columns + .iter() + .map(|c| { + table + .columns + .get(c.pos_in_table) + .unwrap() + .collation + .unwrap_or_default() + }) .collect() }); let cursor = BTreeCursor::new_index( diff --git a/testing/collate.test b/testing/collate.test index 5760a82d1..468297d82 100755 --- a/testing/collate.test +++ b/testing/collate.test @@ -45,3 +45,8 @@ do_execsql_test_in_memory_any_error collate_unique_constraint { CREATE TABLE t(a TEXT COLLATE NOCASE PRIMARY KEY); INSERT INTO t VALUES ('lol'), ('LOL'), ('lOl'); } + +do_execsql_test_in_memory_any_error collate_unique_constraint { + CREATE TABLE t(a TEXT COLLATE NOCASE PRIMARY KEY); + INSERT INTO t VALUES ('lol'), ('LOL'), ('lOl'); +}