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 26, 2023
2 parents 3a9665b + 32c4cb9 commit 4d68adf
Show file tree
Hide file tree
Showing 38 changed files with 3,214 additions and 1,351 deletions.
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ for:
install:
- |-
cd C:\Tools\vcpkg
git fetch --tags && git checkout 2023.10.19
git fetch --tags && git checkout 2023.11.20
cd %APPVEYOR_BUILD_FOLDER%
C:\Tools\vcpkg\bootstrap-vcpkg.bat -disableMetrics
C:\Tools\vcpkg\vcpkg integrate install
Expand Down Expand Up @@ -140,7 +140,7 @@ for:
install:
- |-
pushd $HOME/vcpkg
git fetch --tags && git checkout 2023.10.19
git fetch --tags && git checkout 2023.11.20
popd
$HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
Expand Down Expand Up @@ -168,7 +168,7 @@ for:
# using custom vcpkg triplets for building and linking dynamic dependent libraries
install:
- |-
git clone --depth 1 --branch 2023.10.19 https://github.com/microsoft/vcpkg.git $HOME/vcpkg
git clone --depth 1 --branch 2023.11.20 https://github.com/microsoft/vcpkg.git $HOME/vcpkg
$HOME/vcpkg/bootstrap-vcpkg.sh -disableMetrics
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
vcpkg install sqlite3[core,dbstat,math,json1,fts5] catch2 --overlay-triplets=vcpkg/triplets
Expand Down
44 changes: 10 additions & 34 deletions dev/alias.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#pragma once

#include <type_traits> // std::enable_if, std::is_base_of, std::is_member_pointer, std::remove_const
#include <utility> // std::index_sequence, std::make_index_sequence
#include <type_traits> // std::enable_if, std::is_same, std::conditional
#include <utility> // std::make_index_sequence, std::move
#include <string> // std::string
#include <sstream> // std::stringstream
#include <algorithm> // std::copy_n
#include <string> // std::string
#ifdef SQLITE_ORM_WITH_CTE
#include <array>
#endif

#include "functional/cxx_universal.h" // ::size_t
#include "functional/cxx_type_traits_polyfill.h"
#include "functional/cstring_literal.h"
#include "type_traits.h"
#include "alias_traits.h"
#include "table_type_of.h"
Expand All @@ -21,29 +20,7 @@
namespace sqlite_orm {

namespace internal {

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
/*
* Helper class to facilitate user-defined string literal operator template
*/
template<size_t N>
struct string_identifier_template {
static constexpr size_t size() {
return N - 1;
}

constexpr string_identifier_template(const char (&id)[N]) {
std::copy_n(id, N, this->id);
}

char id[N];
};

template<template<char...> class Alias, string_identifier_template t, size_t... Idx>
consteval auto to_alias(std::index_sequence<Idx...>) {
return Alias<t.id[Idx]...>{};
}

template<class T>
inline constexpr bool is_operator_argument_v<T, std::enable_if_t<orm_column_alias<T>>> = true;
#endif
Expand Down Expand Up @@ -269,7 +246,7 @@ namespace sqlite_orm {
requires(!orm_cte_moniker<internal::auto_type_t<als>>)
constexpr auto alias_column(C field) {
using namespace ::sqlite_orm::internal;
using A = std::remove_const_t<decltype(als)>;
using A = decltype(als);
using aliased_type = type_t<A>;
static_assert(is_field_of_v<C, aliased_type>, "Column must be from aliased table");

Expand Down Expand Up @@ -359,8 +336,7 @@ namespace sqlite_orm {
*/
template<orm_column_alias auto als, class E>
auto as(E expression) {
using A = std::remove_const_t<decltype(als)>;
return internal::as_t<A, E>{std::move(expression)};
return internal::as_t<decltype(als), E>{std::move(expression)};
}

/**
Expand Down Expand Up @@ -392,7 +368,7 @@ namespace sqlite_orm {
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
template<orm_column_alias auto als>
auto get() {
return internal::alias_holder<std::remove_const_t<decltype(als)>>{};
return internal::alias_holder<decltype(als)>{};
}
#endif

Expand Down Expand Up @@ -473,18 +449,18 @@ namespace sqlite_orm {
* Examples:
* constexpr auto z_alias = "z"_alias.for_<User>();
*/
template<internal::string_identifier_template t>
template<internal::cstring_literal name>
[[nodiscard]] consteval auto operator"" _alias() {
return internal::to_alias<internal::recordset_alias_builder, t>(std::make_index_sequence<t.size()>{});
return internal::explode_into<internal::recordset_alias_builder, name>(std::make_index_sequence<name.size()>{});
}

/** @short Create a column alias.
* column_alias<'a'[, ...]> from a string literal.
* E.g. "a"_col, "b"_col
*/
template<internal::string_identifier_template t>
template<internal::cstring_literal name>
[[nodiscard]] consteval auto operator"" _col() {
return internal::to_alias<internal::column_alias, t>(std::make_index_sequence<t.size()>{});
return internal::explode_into<internal::column_alias, name>(std::make_index_sequence<name.size()>{});
}
#endif

Expand Down
14 changes: 10 additions & 4 deletions dev/alias_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace sqlite_orm {
template<class A>
concept orm_alias = std::derived_from<A, alias_tag>;

/** @short Alias of a column in a record set.
/** @short Specifies that a type is an alias of a column in a record set.
*
* A column alias has the following traits:
* - is derived from `alias_tag`
Expand All @@ -97,7 +97,7 @@ namespace sqlite_orm {
template<class A>
concept orm_column_alias = (orm_alias<A> && !orm_names_type<A>);

/** @short Alias of any type of record set.
/** @short Specifies that a type is an alias of any type of record set.
*
* A record set alias has the following traits:
* - is derived from `alias_tag`.
Expand All @@ -106,7 +106,7 @@ namespace sqlite_orm {
template<class A>
concept orm_recordset_alias = (orm_alias<A> && orm_names_type<A>);

/** @short Alias of a concrete table.
/** @short Specifies that a type is an alias of a concrete table.
*
* A concrete table alias has the following traits:
* - is derived from `alias_tag`.
Expand All @@ -115,7 +115,7 @@ namespace sqlite_orm {
template<class A>
concept orm_table_alias = (orm_recordset_alias<A> && !std::same_as<typename A::type, std::remove_const_t<A>>);

/** @short Reference of a concrete table, especially of a derived class.
/** @short Specifies that a type is a reference of a concrete table, especially of a derived class.
*
* A concrete table reference has the following traits:
* - specialization of `table_reference`, whose `type` typename references a mapped object.
Expand All @@ -132,12 +132,18 @@ namespace sqlite_orm {
template<class A>
concept orm_cte_moniker = (orm_recordset_alias<A> && std::same_as<typename A::type, std::remove_const_t<A>>);

/** @short Specifies that a type refers to a mapped table (possibly aliased).
*/
template<class T>
concept orm_refers_to_table = (orm_table_reference<T> || orm_table_alias<T>);

/** @short Specifies that a type refers to a recordset.
*/
template<class T>
concept orm_refers_to_recordset = (orm_table_reference<T> || orm_recordset_alias<T>);

/** @short Specifies that a type is a mapped recordset (table reference).
*/
template<class T>
concept orm_mapped_recordset = (orm_table_reference<T> || orm_cte_moniker<T>);
#endif
Expand Down
8 changes: 4 additions & 4 deletions dev/ast_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,13 @@ namespace sqlite_orm {
}
};

template<class F, class... Args>
struct ast_iterator<function_call<F, Args...>, void> {
using node_type = function_call<F, Args...>;
template<class F, class... CallArgs>
struct ast_iterator<function_call<F, CallArgs...>, void> {
using node_type = function_call<F, CallArgs...>;

template<class L>
void operator()(const node_type& f, L& lambda) const {
iterate_ast(f.args, lambda);
iterate_ast(f.callArgs, lambda);
}
};

Expand Down
5 changes: 2 additions & 3 deletions dev/column_pointer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <type_traits> // std::enable_if, std::remove_const
#include <type_traits> // std::enable_if
#include <utility> // std::move

#include "functional/cxx_core_features.h"
Expand Down Expand Up @@ -59,8 +59,7 @@ namespace sqlite_orm {
*/
template<orm_table_reference auto table, class O, class F>
constexpr auto column(F O::*field) {
using R = std::remove_const_t<decltype(table)>;
return column<typename R::type>(field);
return column<internal::auto_type_t<table>>(field);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions dev/cte_moniker.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#endif

#include "functional/cxx_universal.h"
#include "functional/cstring_literal.h"
#include "alias.h"

#ifdef SQLITE_ORM_WITH_CTE
Expand Down Expand Up @@ -77,9 +78,9 @@ namespace sqlite_orm {
* cte_moniker<'1'[, ...]> from a string literal.
* E.g. "1"_cte, "2"_cte
*/
template<internal::string_identifier_template t>
template<internal::cstring_literal moniker>
[[nodiscard]] consteval auto operator"" _cte() {
return internal::to_alias<internal::cte_moniker, t>(std::make_index_sequence<t.size()>{});
return internal::explode_into<internal::cte_moniker, moniker>(std::make_index_sequence<moniker.size()>{});
}
#endif
}
Expand Down
Loading

0 comments on commit 4d68adf

Please sign in to comment.