From 660d3e8d070d1ba099dfafe8cf6e87f055ad980f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ko=C5=82odziej?= Date: Tue, 10 Dec 2024 22:48:50 +0100 Subject: [PATCH] fix: count characters in string in length function `length` function should count characters, not bytes. https://www.sqlite.org/lang_corefunc.html#length --- core/vdbe/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index a42b449cd..191d66684 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -2537,7 +2537,7 @@ fn exec_lower(reg: &OwnedValue) -> Option { 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()),