mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 12:04:21 +01:00
javascript: Fix Statement.get() for boundary values
This commit is contained in:
@@ -281,12 +281,19 @@ impl Statement {
|
||||
ValueType::Null => turso_core::Value::Null,
|
||||
ValueType::Number => {
|
||||
let n: f64 = unsafe { value.cast()? };
|
||||
if n.fract() == 0.0 {
|
||||
if n.fract() == 0.0 && n >= i64::MIN as f64 && n <= i64::MAX as f64 {
|
||||
turso_core::Value::Integer(n as i64)
|
||||
} else {
|
||||
turso_core::Value::Float(n)
|
||||
}
|
||||
}
|
||||
ValueType::BigInt => {
|
||||
let bigint_str = value.coerce_to_string()?.into_utf8()?.as_str()?.to_owned();
|
||||
let bigint_value = bigint_str.parse::<i64>().map_err(|e| {
|
||||
Error::new(Status::NumberExpected, format!("Failed to parse BigInt: {e}"))
|
||||
})?;
|
||||
turso_core::Value::Integer(bigint_value)
|
||||
}
|
||||
ValueType::String => {
|
||||
let s = value.coerce_to_string()?.into_utf8()?;
|
||||
turso_core::Value::Text(s.as_str()?.to_owned().into())
|
||||
|
||||
Reference in New Issue
Block a user