mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-07-07 20:45:01 +00:00
Get the table correctly from the connection instead of table_references + test to confirm unique constraint
This commit is contained in:
parent
4a3119786e
commit
5b15d6aa32
4 changed files with 34 additions and 31 deletions
|
@ -611,10 +611,6 @@ impl ProgramBuilder {
|
||||||
self.collation = None;
|
self.collation = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn pop_collation(&mut self) -> Option<CollationSeq> {
|
|
||||||
// self.collations.pop()
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn build(
|
pub fn build(
|
||||||
mut self,
|
mut self,
|
||||||
database_header: Arc<SpinLock<DatabaseHeader>>,
|
database_header: Arc<SpinLock<DatabaseHeader>>,
|
||||||
|
|
|
@ -934,15 +934,11 @@ pub fn op_open_read(
|
||||||
.replace(Cursor::new_btree(cursor));
|
.replace(Cursor::new_btree(cursor));
|
||||||
}
|
}
|
||||||
CursorType::BTreeIndex(index) => {
|
CursorType::BTreeIndex(index) => {
|
||||||
let table = program.table_references.iter().find_map(|table_ref| {
|
let conn = program.connection.upgrade().unwrap();
|
||||||
table_ref.btree().and_then(|table| {
|
let schema = conn.schema.try_read().ok_or(LimboError::SchemaLocked)?;
|
||||||
if table.name == index.table_name {
|
let table = schema
|
||||||
Some(table)
|
.get_table(&index.table_name)
|
||||||
} else {
|
.map_or(None, |table| table.btree());
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
let collations = table.map_or(Vec::new(), |table| {
|
let collations = table.map_or(Vec::new(), |table| {
|
||||||
table
|
table
|
||||||
.column_collations()
|
.column_collations()
|
||||||
|
@ -4243,15 +4239,11 @@ pub fn op_open_write(
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
if let Some(index) = maybe_index {
|
if let Some(index) = maybe_index {
|
||||||
let table = program.table_references.iter().find_map(|table_ref| {
|
let conn = program.connection.upgrade().unwrap();
|
||||||
table_ref.btree().and_then(|table| {
|
let schema = conn.schema.try_read().ok_or(LimboError::SchemaLocked)?;
|
||||||
if table.name == index.table_name {
|
let table = schema
|
||||||
Some(table)
|
.get_table(&index.table_name)
|
||||||
} else {
|
.map_or(None, |table| table.btree());
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
let collations = table.map_or(Vec::new(), |table| {
|
let collations = table.map_or(Vec::new(), |table| {
|
||||||
table
|
table
|
||||||
.column_collations()
|
.column_collations()
|
||||||
|
|
|
@ -5,38 +5,43 @@ source $testdir/tester.tcl
|
||||||
|
|
||||||
# SIMPLE SMOKE TESTS THAT DO NOT DEPEND ON SPECIFIC DATABASE ROWS
|
# SIMPLE SMOKE TESTS THAT DO NOT DEPEND ON SPECIFIC DATABASE ROWS
|
||||||
|
|
||||||
do_execsql_test collate-nocase {
|
do_execsql_test collate_nocase {
|
||||||
SELECT 'hat' == 'hAt' COLLATE NOCASE;
|
SELECT 'hat' == 'hAt' COLLATE NOCASE;
|
||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
do_execsql_test collate-binary-1 {
|
do_execsql_test collate_binary_1 {
|
||||||
SELECT 'hat' == 'hAt' COLLATE BINARY;
|
SELECT 'hat' == 'hAt' COLLATE BINARY;
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
do_execsql_test collate-binary-2 {
|
do_execsql_test collate_binary_2 {
|
||||||
SELECT 'hat' == 'hat' COLLATE BINARY;
|
SELECT 'hat' == 'hat' COLLATE BINARY;
|
||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
do_execsql_test collate-rtrim-1 {
|
do_execsql_test collate_rtrim_1 {
|
||||||
SELECT 'hat' == 'hAt ' COLLATE RTRIM;
|
SELECT 'hat' == 'hAt ' COLLATE RTRIM;
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
do_execsql_test collate-rtrim-2 {
|
do_execsql_test collate_rtrim_2 {
|
||||||
SELECT 'hat' == 'hat ' COLLATE RTRIM;
|
SELECT 'hat' == 'hat ' COLLATE RTRIM;
|
||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
do_execsql_test collate-rtrim-3 {
|
do_execsql_test collate_rtrim_3 {
|
||||||
SELECT 'hat' == ' hAt ' COLLATE RTRIM;
|
SELECT 'hat' == ' hAt ' COLLATE RTRIM;
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
do_execsql_test collate-rtrim-4 {
|
do_execsql_test collate_rtrim_4 {
|
||||||
SELECT 'hat' == ' hat ' COLLATE RTRIM;
|
SELECT 'hat' == ' hat ' COLLATE RTRIM;
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
do_execsql_test collate-left-precedence {
|
do_execsql_test collate_left_precedence {
|
||||||
SELECT 'hat' COLLATE BINARY == 'hAt' COLLATE NOCASE;
|
SELECT 'hat' COLLATE BINARY == 'hAt' COLLATE NOCASE;
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
do_execsql_test collate-left-precedence-2 {
|
do_execsql_test collate_left_precedence_2 {
|
||||||
SELECT 'hat' COLLATE NOCASE == 'hAt' COLLATE BINARY;
|
SELECT 'hat' COLLATE NOCASE == 'hAt' COLLATE BINARY;
|
||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
|
do_execsql_test_in_memory_error_content collate_unique_constraint {
|
||||||
|
CREATE TABLE t(a TEXT COLLATE NOCASE PRIMARY KEY);
|
||||||
|
INSERT INTO t VALUES ('lol'), ('LOL'), ('lOl');
|
||||||
|
} {Runtime error: UNIQUE constraint failed: t.a (19)}
|
||||||
|
|
|
@ -226,3 +226,13 @@ proc do_execsql_test_in_memory_any_error {test_name sql_statements} {
|
||||||
set combined_sql [string trim $sql_statements]
|
set combined_sql [string trim $sql_statements]
|
||||||
run_test_expecting_any_error $::sqlite_exec $db_name $combined_sql
|
run_test_expecting_any_error $::sqlite_exec $db_name $combined_sql
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc do_execsql_test_in_memory_error_content {test_name sql_statements expected_error_text} {
|
||||||
|
test_put "Running error content test" in-memory $test_name
|
||||||
|
|
||||||
|
# Use ":memory:" special filename for in-memory database
|
||||||
|
set db_name ":memory:"
|
||||||
|
|
||||||
|
set combined_sql [string trim $sql_statements]
|
||||||
|
run_test_expecting_error_content $::sqlite_exec $db_name $combined_sql $expected_error_text
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue