Make sure we can use boolean values in conditions; fixes #74 (#75)

This commit is contained in:
Dr. Patrick Urbanke (劉自成)
2025-10-23 23:30:58 +02:00
committed by GitHub
parent 15108fba46
commit 91e993ffdd
12 changed files with 404 additions and 6 deletions

View File

@@ -4,7 +4,6 @@
#include <rfl.hpp>
#include "../Ref.hpp"
#include "Column.hpp"
#include "ColumnOrValue.hpp"
#include "Operation.hpp"
@@ -16,6 +15,10 @@ struct Condition {
Ref<Condition> cond2;
};
struct BooleanColumnOrValue {
ColumnOrValue col_or_val;
};
struct Equal {
Operation op1;
Operation op2;
@@ -84,9 +87,9 @@ struct Condition {
};
using ReflectionType =
rfl::TaggedUnion<"what", And, Equal, GreaterEqual, GreaterThan, In,
IsNull, IsNotNull, LesserEqual, LesserThan, Like, Not,
NotEqual, NotIn, NotLike, Or>;
rfl::TaggedUnion<"what", And, BooleanColumnOrValue, Equal, GreaterEqual,
GreaterThan, In, IsNull, IsNotNull, LesserEqual,
LesserThan, Like, Not, NotEqual, NotIn, NotLike, Or>;
const ReflectionType& reflection() const { return val; }

View File

@@ -13,6 +13,10 @@ struct Duration {
int64_t val;
};
struct Boolean {
bool val;
};
struct Float {
double val;
};
@@ -30,8 +34,8 @@ struct Timestamp {
};
struct Value {
using ReflectionType =
rfl::TaggedUnion<"type", Duration, Float, Integer, String, Timestamp>;
using ReflectionType = rfl::TaggedUnion<"type", Duration, Boolean, Float,
Integer, String, Timestamp>;
const auto& reflection() const { return val; }
ReflectionType val;
};

View File

@@ -20,6 +20,9 @@ struct ToValue {
if constexpr (std::is_floating_point_v<Type>) {
return dynamic::Value{dynamic::Float{.val = static_cast<double>(_t)}};
} else if constexpr (std::is_same_v<Type, bool>) {
return dynamic::Value{dynamic::Boolean{.val = _t}};
} else if constexpr (std::is_integral_v<Type>) {
return dynamic::Value{dynamic::Integer{.val = static_cast<int64_t>(_t)}};