Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dev/alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace sqlite_orm {
is_operator_argument_v<T, std::enable_if_t<polyfill::is_specialization_of<T, alias_column_t>::value>> =
true;

struct basic_table;
struct table_identifier;

/*
* Encapsulates extracting the alias identifier of a non-alias.
Expand All @@ -77,7 +77,7 @@ namespace sqlite_orm {
return {};
}

template<class X = basic_table>
template<class X = table_identifier>
static const std::string& as_qualifier(const X& table) {
return table.name;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ namespace sqlite_orm {

// for regular table aliases -> alias identifier
template<class T = A, satisfies<is_table_alias, T> = true>
static std::string as_qualifier(const basic_table&) {
static std::string as_qualifier(const table_identifier&) {
return alias_extractor::extract();
}
};
Expand Down
4 changes: 2 additions & 2 deletions dev/ast_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ namespace sqlite_orm {
ast_iterator<T> iterator;

// possibly invoke lambda with node itself
if constexpr (polyfill::is_invocable<L, polyfill::bool_constant<true>, const T&>::value) {
lambda(polyfill::bool_constant<true>{}, t);
if constexpr (polyfill::is_invocable<L, std::true_type, const T&>::value) {
lambda(std::true_type{}, t);
}

iterator(t, lambda);
Expand Down
2 changes: 1 addition & 1 deletion dev/column_names_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace sqlite_orm {
if constexpr (is_alias<T>::value) {
collectedExpressions.push_back(quote_identifier(alias_extractor<T>::extract()) + ".*");
} else if (!context.omit_table_name) {
const basic_table& table = pick_table<mapped_type_proxy_t<T>>(context.db_objects);
const table_identifier& table = pick_table<mapped_type_proxy_t<T>>(context.db_objects);
collectedExpressions.push_back(quote_identifier(table.name) + ".*");
} else {
collectedExpressions.emplace_back("*");
Expand Down
12 changes: 12 additions & 0 deletions dev/constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,18 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
internal::table_content_t<T> content() {
return {};
}

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
/**
* content='table' table constraint builder function. Used in FTS virtual tables.
*
* https://www.sqlite.org/fts5.html#external_content_tables
*/
template<orm_table_reference auto table>
auto content() {
return content<internal::auto_decay_table_ref_t<table>>();
}
#endif
#endif

/**
Expand Down
23 changes: 19 additions & 4 deletions dev/cte_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "table_type_of.h"
#include "column_result.h"
#include "select_constraints.h"
#include "schema/table.h"
#include "schema/table_base.h"
#include "alias.h"
#include "cte_types.h"
#include "cte_column_names_collector.h"
Expand Down Expand Up @@ -64,6 +64,21 @@ namespace sqlite_orm {
FinalColRefs,
Result>::type;

template<class Mapper, class... Cs>
struct cte_table : table_identifier, table_definition<Cs...> {
using definition_type = table_definition<Cs...>;
using cte_mapper_type = Mapper;
using cte_moniker_type = typename cte_mapper_type::cte_moniker_type;
using object_type = cte_moniker_type;
using elements_type = typename definition_type::elements_type;
};

template<class Mapper, class... Cs>
cte_table<Mapper, Cs...> make_cte_table(std::string name, Cs... args) {
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(args)...)});
}

// aliased column expressions, explicit or implicitly numbered
template<typename F, typename ColRef, satisfies_is_specialization_of<ColRef, alias_holder> = true>
auto make_cte_column(std::string name, const ColRef& /*finalColRef*/) {
Expand Down Expand Up @@ -270,14 +285,14 @@ namespace sqlite_orm {
std::vector<std::string> columnNames,
const ColRefs& finalColRefs,
std::index_sequence<CIs...>) {
return make_table<Mapper>(
return make_cte_table<Mapper>(
std::move(tableName),
make_cte_column<std::tuple_element_t<CIs, typename Mapper::fields_type>>(std::move(columnNames.at(CIs)),
get<CIs>(finalColRefs))...);
}

template<typename DBOs, typename CTE>
auto make_cte_table(const DBOs& dbObjects, const CTE& cte) {
auto make_cte_db_object(const DBOs& dbObjects, const CTE& cte) {
using cte_type = CTE;

auto subSelect = get_cte_driving_subselect(cte.subselect);
Expand Down Expand Up @@ -315,7 +330,7 @@ namespace sqlite_orm {
decltype(auto) make_recursive_cte_db_objects(const DBOs& dbObjects,
const common_table_expressions<CTEs...>& cte,
std::index_sequence<Ii, In...>) {
auto tbl = make_cte_table(dbObjects, get<Ii>(cte));
auto tbl = make_cte_db_object(dbObjects, get<Ii>(cte));

if constexpr (sizeof...(In) > 0) {
return make_recursive_cte_db_objects(
Expand Down
2 changes: 1 addition & 1 deletion dev/cte_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace sqlite_orm {

/**
* This class captures various properties and aspects of a subselect's column expression,
* and is used as a proxy in table_t<>.
* and is used as a proxy in base_table<>.
*/
template<typename Moniker,
typename ExplicitColRefs,
Expand Down
4 changes: 4 additions & 0 deletions dev/functional/cxx_core_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
#define SQLITE_ORM_CLASSTYPE_TEMPLATE_ARGS_SUPPORTED
#endif

#if __cpp_explicit_this_parameter >= 202110L
#define SQLITE_ORM_DEDUCING_THIS_SUPPORTED
#endif

#if __cpp_static_call_operator >= 202207L
#define SQLITE_ORM_STATIC_CALL_OPERATOR_SUPPORTED
#endif
Expand Down
2 changes: 1 addition & 1 deletion dev/implementations/column_definitions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @file Mainly existing to disentangle implementation details from circular and cross dependencies
* (e.g. column_t -> default_value_extractor -> serializer_context -> db_objects_tuple -> table_t -> column_t)
* (e.g. column_t -> default_value_extractor -> serializer_context -> db_objects_tuple -> base_table -> column_t)
* this file is also used to provide definitions of interface methods 'hitting the database'.
*/
#pragma once
Expand Down
8 changes: 4 additions & 4 deletions dev/implementations/storage_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace sqlite_orm {
namespace internal {
template<class... DBO>
template<class Table, satisfies<is_table, Table>>
template<class Table, satisfies<is_base_table, Table>>
sync_schema_result storage_t<DBO...>::sync_dbo([[maybe_unused]] const Table& table,
[[maybe_unused]] sqlite3* db,
[[maybe_unused]] bool preserve) {
Expand All @@ -34,13 +34,13 @@ namespace sqlite_orm {
std::is_same<object_type_t<Table>, sqlite_master>::value) {
return sync_schema_result::already_in_sync;
} else {
return this->sync_regular_table(table, db, preserve);
return this->sync_regular_base_table(table, db, preserve);
}
}

template<class... DBO>
template<class Table, satisfies<is_table, Table>>
sync_schema_result storage_t<DBO...>::sync_regular_table(const Table& table, sqlite3* db, bool preserve) {
template<class Table, satisfies<is_base_table, Table>>
sync_schema_result storage_t<DBO...>::sync_regular_base_table(const Table& table, sqlite3* db, bool preserve) {
auto res = sync_schema_result::already_in_sync;
bool attempt_to_preserve = true;

Expand Down
8 changes: 4 additions & 4 deletions dev/implementations/table_definitions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @file Mainly existing to disentangle implementation details from circular and cross dependencies
* (e.g. column_t -> default_value_extractor -> serializer_context -> db_objects_tuple -> table_t -> column_t)
* (e.g. column_t -> default_value_extractor -> serializer_context -> db_objects_tuple -> base_table -> column_t)
* this file is also used to provide definitions of interface methods 'hitting the database'.
*/
#pragma once
Expand All @@ -19,10 +19,10 @@
namespace sqlite_orm {
namespace internal {

template<class T, bool WithoutRowId, class... Cs>
std::vector<table_xinfo> table_t<T, WithoutRowId, Cs...>::get_table_info() const {
template<class T, class WithoutRowId, class... Cs>
std::vector<table_xinfo> base_table<T, WithoutRowId, Cs...>::get_table_info() const {
std::vector<table_xinfo> res;
res.reserve(filter_tuple_sequence_t<elements_type, is_column>::size());
res.reserve(col_index_sequence_of<elements_type>::size());
this->for_each_column([&res](auto& column) {
using field_type = field_type_t<std::remove_reference_t<decltype(column)>>;
std::string dft;
Expand Down
2 changes: 1 addition & 1 deletion dev/interface_definitions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @file Mainly existing to disentangle implementation details from circular and cross dependencies
* (e.g. column_t -> default_value_extractor -> serializer_context -> db_objects_tuple -> table_t -> column_t)
* (e.g. column_t -> default_value_extractor -> serializer_context -> db_objects_tuple -> base_table -> column_t)
* this file is also used to provide definitions of interface methods 'hitting the database'.
*/
#pragma once
Expand Down
Loading