Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into CTEs
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed Nov 9, 2023
2 parents 60954f2 + 79f1117 commit e3d9cc2
Show file tree
Hide file tree
Showing 21 changed files with 486 additions and 487 deletions.
4 changes: 2 additions & 2 deletions dev/column_names_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ namespace sqlite_orm {
(*this)(colExpr, context);
});
// note: `capacity() > size()` can occur in case `asterisk_t<>` does spell out the columns in defined order
if(mpl::instantiate<check_if_tuple_has_template<asterisk_t>,
typename columns_t<Args...>::columns_type>::value &&
if(mpl::invoke_t<check_if_tuple_has_template<asterisk_t>,
typename columns_t<Args...>::columns_type>::value &&
collectedExpressions.capacity() > collectedExpressions.size()) {
collectedExpressions.shrink_to_fit();
}
Expand Down
23 changes: 13 additions & 10 deletions dev/column_result.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#pragma once

#include <type_traits> // std::enable_if, std::is_same, std::decay, std::is_arithmetic, std::is_base_of
#include <tuple> // std::tuple
#include <functional> // std::reference_wrapper

#include "functional/cxx_universal.h"
#include "functional/cxx_universal.h" // ::nullptr_t
#include "functional/cxx_type_traits_polyfill.h"
#include "functional/mpl.h"
#include "tuple_helper/tuple_traits.h"
#include "tuple_helper/tuple_fy.h"
#include "tuple_helper/tuple_filter.h"
#include "tuple_helper/tuple_transformer.h"
#include "tuple_helper/same_or_void.h"
#include "type_traits.h"
#include "member_traits/member_traits.h"
Expand Down Expand Up @@ -45,6 +46,10 @@ namespace sqlite_orm {
template<class DBOs, class T>
using column_result_of_t = typename column_result_t<DBOs, T>::type;

template<class DBOs, class Tpl>
using column_result_for_tuple_t =
transform_tuple_t<Tpl, mpl::bind_front_fn<column_result_of_t, DBOs>::template fn>;

#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
template<class DBOs, class T>
struct column_result_t<DBOs, as_optional_t<T>, void> {
Expand Down Expand Up @@ -241,20 +246,18 @@ namespace sqlite_orm {
#endif

template<class DBOs, class... Args>
struct column_result_t<DBOs, columns_t<Args...>, void> {
using type = tuple_cat_t<tuplify_t<column_result_of_t<DBOs, std::decay_t<Args>>>...>;
};
struct column_result_t<DBOs, columns_t<Args...>, void>
: conc_tuple<tuplify_t<column_result_of_t<DBOs, std::decay_t<Args>>>...> {};

template<class DBOs, class T, class... Args>
struct column_result_t<DBOs, select_t<T, Args...>> : column_result_t<DBOs, T> {};

template<class DBOs, class T>
struct column_result_t<DBOs, T, match_if<is_compound_operator, T>> {
using column_result_fn = mpl::bind_front_fn<column_result_of_t, DBOs>;
using types_tuple = transform_tuple_t<typename T::expressions_tuple, column_result_fn::template fn>;
using type = std::tuple_element_t<0, types_tuple>;
static_assert(!std::is_same<void, same_or_void_of_t<types_tuple>>::value,
"Compound subselect queries must return same types");
using type =
polyfill::detected_t<common_type_of_t, column_result_for_tuple_t<DBOs, typename T::expressions_tuple>>;
static_assert(!std::is_same<type, polyfill::nonesuch>::value,
"Compound select statements must return a common type");
};

template<class DBOs, class T>
Expand Down
26 changes: 13 additions & 13 deletions dev/constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,25 +458,25 @@ namespace sqlite_orm {
template<typename T>
struct is_primary_key_insertable
: polyfill::disjunction<
mpl::instantiate<mpl::disjunction<check_if_tuple_has_template<default_t>,
check_if_tuple_has_template<primary_key_with_autoincrement>>,
constraints_type_t<T>>,
mpl::invoke_t<mpl::disjunction<check_if_tuple_has_template<default_t>,
check_if_tuple_has_template<primary_key_with_autoincrement>>,
constraints_type_t<T>>,
std::is_base_of<integer_printer, type_printer<field_type_t<T>>>> {

static_assert(tuple_has<is_primary_key, constraints_type_t<T>>::value, "an unexpected type was passed");
};

template<class T>
using is_constraint = mpl::instantiate<mpl::disjunction<check_if<is_primary_key>,
check_if<is_foreign_key>,
check_if_is_type<null_t>,
check_if_is_type<not_null_t>,
check_if_is_template<unique_t>,
check_if_is_template<default_t>,
check_if_is_template<check_t>,
check_if_is_type<collate_constraint_t>,
check_if<is_generated_always>>,
T>;
using is_constraint = mpl::invoke_t<mpl::disjunction<check_if<is_primary_key>,
check_if<is_foreign_key>,
check_if_is_type<null_t>,
check_if_is_type<not_null_t>,
check_if_is_template<unique_t>,
check_if_is_template<default_t>,
check_if_is_template<check_t>,
check_if_is_type<collate_constraint_t>,
check_if<is_generated_always>>,
T>;
}

#if SQLITE_VERSION_NUMBER >= 3031000
Expand Down
6 changes: 6 additions & 0 deletions dev/functional/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#define SQLITE_ORM_INLINE_VAR
#endif

#if __cpp_lib_constexpr_functional >= 201907L
#define SQLITE_ORM_CONSTEXPR_CPP20 constexpr
#else
#define SQLITE_ORM_CONSTEXPR_CPP20
#endif

#if SQLITE_ORM_HAS_CPP_ATTRIBUTE(no_unique_address) >= 201803L
#define SQLITE_ORM_NOUNIQUEADDRESS [[no_unique_address]]
#else
Expand Down
Loading

0 comments on commit e3d9cc2

Please sign in to comment.