Fix #1732 - casting string containing decimal to int. (#1734)

This commit is contained in:
Finn Bear 2023-03-29 11:23:13 -07:00 committed by GitHub
parent e0cad89a8c
commit 50ea5c52cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -803,7 +803,7 @@ impl Value {
pub fn as_int(self) -> i64 { pub fn as_int(self) -> i64 {
match self { match self {
Value::True => 1, Value::True => 1,
Value::Strand(v) => v.parse::<i64>().unwrap_or(0), Value::Strand(v) => Number::from(v.as_str()).as_int(),
Value::Number(v) => v.as_int(), Value::Number(v) => v.as_int(),
Value::Duration(v) => v.as_secs() as i64, Value::Duration(v) => v.as_secs() as i64,
Value::Datetime(v) => v.timestamp(), Value::Datetime(v) => v.timestamp(),