fix: count characters in string in length function

`length` function should count characters, not bytes.

https://www.sqlite.org/lang_corefunc.html#length
This commit is contained in:
Kacper Kołodziej
2024-12-10 22:48:50 +01:00
parent e68a86532a
commit 660d3e8d07

View File

@@ -2537,7 +2537,7 @@ fn exec_lower(reg: &OwnedValue) -> Option<OwnedValue> {
fn exec_length(reg: &OwnedValue) -> OwnedValue {
match reg {
OwnedValue::Text(_) | OwnedValue::Integer(_) | OwnedValue::Float(_) => {
OwnedValue::Integer(reg.to_string().len() as i64)
OwnedValue::Integer(reg.to_string().chars().count() as i64)
}
OwnedValue::Blob(blob) => OwnedValue::Integer(blob.len() as i64),
OwnedValue::Agg(aggctx) => exec_length(aggctx.final_value()),