@@ -4168,6 +4168,24 @@ namespace sqlite_orm {
41684168 template<class L, class R>
41694169 using conc_t = binary_operator<L, R, conc_string>;
41704170
4171+ struct unary_minus_string {
4172+ serialize_result_type serialize() const {
4173+ return "-";
4174+ }
4175+ };
4176+
4177+ /**
4178+ * Result of unary minus - operator
4179+ */
4180+ template<class T>
4181+ struct unary_minus_t : unary_minus_string, arithmetic_t, negatable_t {
4182+ using argument_type = T;
4183+
4184+ argument_type argument;
4185+
4186+ unary_minus_t(argument_type argument_) : argument(std::move(argument_)) {}
4187+ };
4188+
41714189 struct add_string {
41724190 serialize_result_type serialize() const {
41734191 return "+";
@@ -4187,7 +4205,7 @@ namespace sqlite_orm {
41874205 };
41884206
41894207 /**
4190- * Result of substitute - operator
4208+ * Result of substraction - operator
41914209 */
41924210 template<class L, class R>
41934211 using sub_t = binary_operator<L, R, sub_string, arithmetic_t, negatable_t>;
@@ -4328,6 +4346,11 @@ namespace sqlite_orm {
43284346 return {std::move(l), std::move(r)};
43294347 }
43304348
4349+ template<class T>
4350+ constexpr internal::unary_minus_t<T> minus(T t) {
4351+ return {std::move(t)};
4352+ }
4353+
43314354 /**
43324355 * Public interface for + operator. Example: `select(add(&User::age, 100));` => SELECT age + 100 FROM users
43334356 */
@@ -8091,6 +8114,14 @@ namespace sqlite_orm {
80918114 // Intentionally place operators for types classified as arithmetic or general operator arguments in the internal namespace
80928115 // to facilitate ADL (Argument Dependent Lookup)
80938116 namespace internal {
8117+ template<
8118+ class T,
8119+ std::enable_if_t<polyfill::disjunction<std::is_base_of<arithmetic_t, T>, is_operator_argument<T>>::value,
8120+ bool> = true>
8121+ constexpr unary_minus_t<unwrap_expression_t<T>> operator-(T arg) {
8122+ return {get_from_expression(std::forward<T>(arg))};
8123+ }
8124+
80948125 template<class L,
80958126 class R,
80968127 std::enable_if_t<polyfill::disjunction<std::is_base_of<arithmetic_t, L>,
@@ -11474,6 +11505,11 @@ namespace sqlite_orm {
1147411505 using type = std::string;
1147511506 };
1147611507
11508+ template<class DBOs, class T>
11509+ struct column_result_t<DBOs, unary_minus_t<T>, void> {
11510+ using type = double;
11511+ };
11512+
1147711513 template<class DBOs, class L, class R>
1147811514 struct column_result_t<DBOs, add_t<L, R>, void> {
1147911515 using type = double;
@@ -19941,8 +19977,11 @@ namespace sqlite_orm {
1994119977 };
1994219978
1994319979 template<class T>
19944- struct statement_serializer<bitwise_not_t<T>, void> {
19945- using statement_type = bitwise_not_t<T>;
19980+ struct statement_serializer<
19981+ T,
19982+ std::enable_if_t<polyfill::disjunction<polyfill::is_specialization_of<T, unary_minus_t>,
19983+ polyfill::is_specialization_of<T, bitwise_not_t>>::value>> {
19984+ using statement_type = T;
1994619985
1994719986 template<class Ctx>
1994819987 std::string operator()(const statement_type& expression, const Ctx& context) const {
@@ -24287,6 +24326,9 @@ namespace sqlite_orm {
2428724326 template<class C>
2428824327 struct node_tuple<negated_condition_t<C>, void> : node_tuple<C> {};
2428924328
24329+ template<class T>
24330+ struct node_tuple<unary_minus_t<T>, void> : node_tuple<T> {};
24331+
2429024332 template<class T>
2429124333 struct node_tuple<bitwise_not_t<T>, void> : node_tuple<T> {};
2429224334
0 commit comments