Skip to content

Commit

Permalink
Merge branch 'upstream/dev' into feature/modules-support
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed Jul 24, 2024
2 parents efbef40 + 662f4e0 commit 996bcbc
Show file tree
Hide file tree
Showing 20 changed files with 336 additions and 180 deletions.
3 changes: 2 additions & 1 deletion dev/ast/set.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ namespace sqlite_orm {
void push_back(assign_t<L, R> assign) {
auto newContext = this->context;
newContext.skip_table_name = true;
iterate_ast(assign, this->collector);
// note: we are only interested in the table name on the left-hand side of the assignment operator expression
iterate_ast(assign.lhs, this->collector);
std::stringstream ss;
ss << serialize(assign.lhs, newContext) << ' ' << assign.serialize() << ' '
<< serialize(assign.rhs, context);
Expand Down
4 changes: 2 additions & 2 deletions dev/ast/where.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace sqlite_orm {

expression_type expression;

where_t(expression_type expression_) : expression(std::move(expression_)) {}
constexpr where_t(expression_type expression_) : expression(std::move(expression_)) {}
};

template<class T>
Expand All @@ -50,7 +50,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
* auto rows = storage.select(&Letter::name, where(greater_than(&Letter::id, 3)));
*/
template<class C>
internal::where_t<C> where(C expression) {
constexpr internal::where_t<C> where(C expression) {
return {std::move(expression)};
}
}
56 changes: 28 additions & 28 deletions dev/conditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace sqlite_orm {
struct negated_condition_t : condition_t, negated_condition_string {
C c;

negated_condition_t(C c_) : c(std::move(c_)) {}
constexpr negated_condition_t(C c_) : c(std::move(c_)) {}
};

/**
Expand All @@ -134,9 +134,9 @@ namespace sqlite_orm {
left_type lhs;
right_type rhs;

binary_condition() = default;
constexpr binary_condition() = default;

binary_condition(left_type l_, right_type r_) : lhs(std::move(l_)), rhs(std::move(r_)) {}
constexpr binary_condition(left_type l_, right_type r_) : lhs(std::move(l_)), rhs(std::move(r_)) {}
};

template<class T>
Expand Down Expand Up @@ -853,7 +853,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
class T,
std::enable_if_t<polyfill::disjunction<std::is_base_of<negatable_t, T>, is_operator_argument<T>>::value,
bool> = true>
negated_condition_t<T> operator!(T arg) {
constexpr negated_condition_t<T> operator!(T arg) {
return {std::move(arg)};
}

Expand All @@ -864,7 +864,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
less_than_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator<(L l, R r) {
constexpr less_than_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator<(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -875,7 +875,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
less_or_equal_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator<=(L l, R r) {
constexpr less_or_equal_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator<=(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -886,7 +886,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
greater_than_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator>(L l, R r) {
constexpr greater_than_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator>(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -897,7 +897,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
greater_or_equal_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator>=(L l, R r) {
constexpr greater_or_equal_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator>=(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -910,7 +910,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
is_equal_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator==(L l, R r) {
constexpr is_equal_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator==(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -923,7 +923,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
is_not_equal_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator!=(L l, R r) {
constexpr is_not_equal_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator!=(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -934,7 +934,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
and_condition_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator&&(L l, R r) {
constexpr and_condition_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator&&(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -943,7 +943,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
std::enable_if_t<
polyfill::disjunction<std::is_base_of<condition_t, L>, std::is_base_of<condition_t, R>>::value,
bool> = true>
or_condition_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator||(L l, R r) {
constexpr or_condition_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator||(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -959,7 +959,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
polyfill::negation<polyfill::disjunction<std::is_base_of<condition_t, L>,
std::is_base_of<condition_t, R>>>>::value,
bool> = true>
conc_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator||(L l, R r) {
constexpr conc_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator||(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}
}
Expand Down Expand Up @@ -1057,14 +1057,14 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
}

template<class L, class R>
auto and_(L l, R r) {
constexpr auto and_(L l, R r) {
using namespace ::sqlite_orm::internal;
return and_condition_t<unwrap_expression_t<L>, unwrap_expression_t<R>>{get_from_expression(std::forward<L>(l)),
get_from_expression(std::forward<R>(r))};
}

template<class L, class R>
auto or_(L l, R r) {
constexpr auto or_(L l, R r) {
using namespace ::sqlite_orm::internal;
return or_condition_t<unwrap_expression_t<L>, unwrap_expression_t<R>>{get_from_expression(std::forward<L>(l)),
get_from_expression(std::forward<R>(r))};
Expand Down Expand Up @@ -1111,52 +1111,52 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
}

template<class L, class R>
internal::is_equal_t<L, R> is_equal(L l, R r) {
constexpr internal::is_equal_t<L, R> is_equal(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::is_equal_t<L, R> eq(L l, R r) {
constexpr internal::is_equal_t<L, R> eq(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::is_equal_with_table_t<L, R> is_equal(R rhs) {
constexpr internal::is_equal_with_table_t<L, R> is_equal(R rhs) {
return {std::move(rhs)};
}

template<class L, class R>
internal::is_not_equal_t<L, R> is_not_equal(L l, R r) {
constexpr internal::is_not_equal_t<L, R> is_not_equal(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::is_not_equal_t<L, R> ne(L l, R r) {
constexpr internal::is_not_equal_t<L, R> ne(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::greater_than_t<L, R> greater_than(L l, R r) {
constexpr internal::greater_than_t<L, R> greater_than(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::greater_than_t<L, R> gt(L l, R r) {
constexpr internal::greater_than_t<L, R> gt(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::greater_or_equal_t<L, R> greater_or_equal(L l, R r) {
constexpr internal::greater_or_equal_t<L, R> greater_or_equal(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::greater_or_equal_t<L, R> ge(L l, R r) {
constexpr internal::greater_or_equal_t<L, R> ge(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::less_than_t<L, R> less_than(L l, R r) {
constexpr internal::less_than_t<L, R> less_than(L l, R r) {
return {std::move(l), std::move(r)};
}

Expand All @@ -1170,12 +1170,12 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
}

template<class L, class R>
internal::less_than_t<L, R> lt(L l, R r) {
constexpr internal::less_than_t<L, R> lt(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::less_or_equal_t<L, R> less_or_equal(L l, R r) {
constexpr internal::less_or_equal_t<L, R> less_or_equal(L l, R r) {
return {std::move(l), std::move(r)};
}

Expand All @@ -1189,7 +1189,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
}

template<class L, class R>
internal::less_or_equal_t<L, R> le(L l, R r) {
constexpr internal::less_or_equal_t<L, R> le(L l, R r) {
return {std::move(l), std::move(r)};
}

Expand Down
10 changes: 5 additions & 5 deletions dev/core_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
add_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator+(L l, R r) {
constexpr add_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator+(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -2067,7 +2067,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
sub_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator-(L l, R r) {
constexpr sub_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator-(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -2078,7 +2078,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
mul_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator*(L l, R r) {
constexpr mul_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator*(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -2089,7 +2089,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
div_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator/(L l, R r) {
constexpr div_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator/(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}

Expand All @@ -2100,7 +2100,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
is_operator_argument<L>,
is_operator_argument<R>>::value,
bool> = true>
mod_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator%(L l, R r) {
constexpr mod_t<unwrap_expression_t<L>, unwrap_expression_t<R>> operator%(L l, R r) {
return {get_from_expression(std::forward<L>(l)), get_from_expression(std::forward<R>(r))};
}
}
Expand Down
4 changes: 2 additions & 2 deletions dev/cte_moniker.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace sqlite_orm {
std::same_as<ExplicitCols, std::remove_cvref_t<decltype(std::ignore)>> ||
std::convertible_to<ExplicitCols, std::string>) &&
...)
auto operator()(ExplicitCols... explicitColumns) const;
constexpr auto operator()(ExplicitCols... explicitColumns) const;
#else
template<class... ExplicitCols,
std::enable_if_t<polyfill::conjunction_v<polyfill::disjunction<
Expand All @@ -61,7 +61,7 @@ namespace sqlite_orm {
std::is_same<ExplicitCols, polyfill::remove_cvref_t<decltype(std::ignore)>>,
std::is_convertible<ExplicitCols, std::string>>...>,
bool> = true>
auto operator()(ExplicitCols... explicitColumns) const;
constexpr auto operator()(ExplicitCols... explicitColumns) const;
#endif
};
}
Expand Down
5 changes: 5 additions & 0 deletions dev/eponymous_vtabs/dbstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "../schema/column.h"
#include "../schema/table.h"
#include "../column_pointer.h"

_EXPORT_SQLITE_ORM namespace sqlite_orm {
#ifdef SQLITE_ENABLE_DBSTAT_VTAB
Expand Down Expand Up @@ -37,5 +38,9 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
make_column("pgoffset", &dbstat::pgoffset),
make_column("pgsize", &dbstat::pgsize));
}

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
inline constexpr orm_table_reference auto dbstat_table = c<dbstat>();
#endif
#endif // SQLITE_ENABLE_DBSTAT_VTAB
}
6 changes: 3 additions & 3 deletions dev/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ namespace sqlite_orm {
is_operator_argument_v<T, std::enable_if_t<polyfill::is_specialization_of<T, expression_t>::value>> = true;

template<class T>
T get_from_expression(T value) {
constexpr T get_from_expression(T value) {
return std::move(value);
}

template<class T>
T get_from_expression(expression_t<T> expression) {
constexpr T get_from_expression(expression_t<T> expression) {
return std::move(expression.value);
}

Expand All @@ -90,7 +90,7 @@ _EXPORT_SQLITE_ORM namespace sqlite_orm {
* `storage.update(set(c(&User::name) = "Dua Lipa"));
*/
template<class T>
internal::expression_t<T> c(T value) {
constexpr internal::expression_t<T> c(T value) {
return {std::move(value)};
}
}
Loading

0 comments on commit 996bcbc

Please sign in to comment.