summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSQL/AST
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-09-22 08:35:47 -0400
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-10-14 17:47:44 +0330
commit7d41b46a7da8e8cbf624a28ba3841618ffa08f48 (patch)
tree36673878f391ef3fabcc54070a304c55ffbf2aae /Userland/Libraries/LibSQL/AST
parentaf3980384bf043ffaf81c82314324bfda5dfb6ff (diff)
downloadserenity-7d41b46a7da8e8cbf624a28ba3841618ffa08f48.zip
LibSQL: Remove infallible type conversions from SQL::Value
Force the callers to either know that the type is convertible, or to handle the conversion failure.
Diffstat (limited to 'Userland/Libraries/LibSQL/AST')
-rw-r--r--Userland/Libraries/LibSQL/AST/Expression.cpp8
-rw-r--r--Userland/Libraries/LibSQL/AST/Select.cpp4
2 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibSQL/AST/Expression.cpp b/Userland/Libraries/LibSQL/AST/Expression.cpp
index 9619648308..8e6cdd2ef2 100644
--- a/Userland/Libraries/LibSQL/AST/Expression.cpp
+++ b/Userland/Libraries/LibSQL/AST/Expression.cpp
@@ -126,23 +126,23 @@ ResultOr<Value> UnaryOperatorExpression::evaluate(ExecutionContext& context) con
return Result { SQLCommand::Unknown, SQLErrorCode::NumericOperatorTypeMismatch, UnaryOperator_name(type()) };
case UnaryOperator::Minus:
if (expression_value.type() == SQLType::Integer) {
- expression_value = -int(expression_value);
+ expression_value = -expression_value.to_int().value();
return expression_value;
}
if (expression_value.type() == SQLType::Float) {
- expression_value = -double(expression_value);
+ expression_value = -expression_value.to_double().value();
return expression_value;
}
return Result { SQLCommand::Unknown, SQLErrorCode::NumericOperatorTypeMismatch, UnaryOperator_name(type()) };
case UnaryOperator::Not:
if (expression_value.type() == SQLType::Boolean) {
- expression_value = !bool(expression_value);
+ expression_value = !expression_value.to_bool().value();
return expression_value;
}
return Result { SQLCommand::Unknown, SQLErrorCode::BooleanOperatorTypeMismatch, UnaryOperator_name(type()) };
case UnaryOperator::BitwiseNot:
if (expression_value.type() == SQLType::Integer) {
- expression_value = ~u32(expression_value);
+ expression_value = ~expression_value.to_u32().value();
return expression_value;
}
return Result { SQLCommand::Unknown, SQLErrorCode::IntegerOperatorTypeMismatch, UnaryOperator_name(type()) };
diff --git a/Userland/Libraries/LibSQL/AST/Select.cpp b/Userland/Libraries/LibSQL/AST/Select.cpp
index 8238c2b1d5..dd2a786d75 100644
--- a/Userland/Libraries/LibSQL/AST/Select.cpp
+++ b/Userland/Libraries/LibSQL/AST/Select.cpp
@@ -92,8 +92,8 @@ ResultOr<ResultSet> Select::execute(ExecutionContext& context) const
context.current_row = &row;
if (where_clause()) {
- auto where_result = TRY(where_clause()->evaluate(context));
- if (!where_result)
+ auto where_result = TRY(where_clause()->evaluate(context)).to_bool();
+ if (!where_result.has_value() || !where_result.value())
continue;
}