Repository: tursodatabase/limbo (language: rust)

Issue:
`SELECT -9223372036854775808` result differs from SQLite
## Issue 

![Image](https://github.com/user-attachments/assets/c87aa7d0-9812-4f11-8be9-012184c76c36)

As you can see above, the result of selecting the min long value differs from sqlite(the result of selecting max long value is same for limbo and sqlite though). 

## ETC 

`-9223372036854775808` + `1` works for limbo 

![Image](https://github.com/user-attachments/assets/1ed5c622-cef9-4e45-b4fd-996bb867487a)


Discussion / hints:
Looking into it.

Fix patch:
diff --git a/core/translate/expr.rs b/core/translate/expr.rs
index 9fdf5f9c2..319a15110 100644
--- a/core/translate/expr.rs
+++ b/core/translate/expr.rs
@@ -1768,22 +1768,33 @@ pub fn translate_expr(
                 UnaryOperator::Negative | UnaryOperator::Positive,
                 ast::Expr::Literal(ast::Literal::Numeric(numeric_value)),
             ) => {
-                let maybe_int = numeric_value.parse::<i64>();
                 let multiplier = if let UnaryOperator::Negative = op {
                     -1
                 } else {
                     1
                 };
-                if let Ok(value) = maybe_int {
+
+                // Special case: if we're negating "9223372036854775808", this is exactly MIN_INT64
+                // If we don't do this -1 * 9223372036854775808 will overflow and parse will fail and trigger conversion to Real.
+                if multiplier == -1 && numeric_value == "9223372036854775808" {
                     program.emit_insn(Insn::Integer {
-                        value: value * multiplier,
+                        value: i64::MIN,
                         dest: target_register,
                     });
                 } else {
-                    program.emit_insn(Insn::Real {
-                        value: multiplier as f64 * numeric_value.parse::<f64>()?,
-                        dest: target_register,
-                    });
+                    let maybe_int = numeric_value.parse::<i64>();
+                    if let Ok(value) = maybe_int {
+                        program.emit_insn(Insn::Integer {
+                            value: value * multiplier,
+                            dest: target_register,
+                        });
+                    } else {
+                        let value = numeric_value.parse::<f64>()?;
+                        program.emit_insn(Insn::Real {
+                            value: value * multiplier as f64,
+                            dest: target_register,
+                        });
+                    }
                 }
                 Ok(target_register)
             }


Test patch: