mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 08:34:19 +01:00
Fix expected error message
This commit is contained in:
@@ -6547,21 +6547,17 @@ pub fn op_must_be_int(
|
||||
Value::Integer(_) => {}
|
||||
Value::Float(f) => match cast_real_to_integer(*f) {
|
||||
Ok(i) => state.registers[*reg] = Register::Value(Value::Integer(i)),
|
||||
Err(_) => crate::bail_parse_error!(
|
||||
"MustBeInt: the value in register cannot be cast to integer"
|
||||
),
|
||||
Err(_) => crate::bail_parse_error!("datatype mismatch"),
|
||||
},
|
||||
Value::Text(text) => match checked_cast_text_to_numeric(text.as_str()) {
|
||||
Ok(Value::Integer(i)) => state.registers[*reg] = Register::Value(Value::Integer(i)),
|
||||
Ok(Value::Float(f)) => {
|
||||
state.registers[*reg] = Register::Value(Value::Integer(f as i64))
|
||||
}
|
||||
_ => crate::bail_parse_error!(
|
||||
"MustBeInt: the value in register cannot be cast to integer"
|
||||
),
|
||||
_ => crate::bail_parse_error!("datatype mismatch"),
|
||||
},
|
||||
_ => {
|
||||
crate::bail_parse_error!("MustBeInt: the value in register cannot be cast to integer");
|
||||
crate::bail_parse_error!("datatype mismatch");
|
||||
}
|
||||
};
|
||||
state.pc += 1;
|
||||
|
||||
@@ -90,26 +90,26 @@ do_execsql_test_on_specific_db {:memory:} offset-expr-int-and-string {
|
||||
|
||||
do_execsql_test_in_memory_error_content offset-expr-cannot-be-cast-losslessly-1 {
|
||||
SELECT 1 LIMIT 3 OFFSET 1.1;
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
do_execsql_test_in_memory_error_content offset-expr-cannot-be-cast-losslessly-2 {
|
||||
SELECT 1 LIMIT 3 OFFSET 1.1 + 2.2 + 1.9/8;
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
# Return error as float in expression cannot be cast losslessly
|
||||
do_execsql_test_in_memory_error_content offset-expr-cannot-be-cast-losslessly-3 {
|
||||
SELECT 1 LIMIT 3 OFFSET 1.1 + 'a';
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
do_execsql_test_in_memory_error_content offset-expr-invalid-data-type-1 {
|
||||
SELECT 1 LIMIT 3 OFFSET 'a';
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
do_execsql_test_in_memory_error_content offset-expr-invalid-data-type-2 {
|
||||
SELECT 1 LIMIT 3 OFFSET NULL;
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
# Expression below evaluates to NULL (string → 0)
|
||||
do_execsql_test_in_memory_error_content offset-expr-invalid-data-type-3 {
|
||||
SELECT 1 LIMIT 3 OFFSET 1/'iwillbezero ;-; ';
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
@@ -979,34 +979,34 @@ do_execsql_test_on_specific_db {:memory:} limit-expr-int-and-string {
|
||||
|
||||
do_execsql_test_in_memory_error_content limit-expr-cannot-be-cast-losslessly-1 {
|
||||
SELECT 1 LIMIT 1.1;
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
do_execsql_test_in_memory_error_content limit-expr-cannot-be-cast-losslessly-2 {
|
||||
SELECT 1 LIMIT 1.1 + 2.2 + 1.9/8;
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
# Return error as float in the expression cannot be cast losslessly
|
||||
do_execsql_test_in_memory_error_content limit-expr-cannot-be-cast-losslessly-3 {
|
||||
SELECT 1 LIMIT 1.1 +'a';
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
do_execsql_test_in_memory_error_content limit-expr-invalid-data-type-1 {
|
||||
SELECT 1 LIMIT 'a';
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
do_execsql_test_in_memory_error_content limit-expr-invalid-data-type-2 {
|
||||
SELECT 1 LIMIT NULL;
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
# The expression below evaluates to NULL as string is cast to 0
|
||||
do_execsql_test_in_memory_error_content limit-expr-invalid-data-type-3 {
|
||||
SELECT 1 LIMIT 1/'iwillbezero ;-; ' ;
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
# Expression is evaluated as NULL
|
||||
do_execsql_test_in_memory_error_content limit-expr-invalid-data-type-4 {
|
||||
SELECT 1 LIMIT 4+NULL;
|
||||
} {"the value in register cannot be cast to integer"}
|
||||
} {"datatype mismatch"}
|
||||
|
||||
do_execsql_test_on_specific_db {:memory:} rowid-references {
|
||||
CREATE TABLE test_table (id INTEGER);
|
||||
|
||||
Reference in New Issue
Block a user