diff --git a/dev/alias.h b/dev/alias.h index 41fbdbd7f..e43d7d382 100644 --- a/dev/alias.h +++ b/dev/alias.h @@ -163,7 +163,13 @@ namespace sqlite_orm { return {}; } - template + template + [[nodiscard]] consteval auto for_() const { + using T = auto_decay_table_ref_t; + return recordset_alias{}; + } + + template [[nodiscard]] consteval auto for_() const { using T = std::remove_const_t; return recordset_alias{}; diff --git a/dev/ast/into.h b/dev/ast/into.h index 2e961be25..b429de419 100644 --- a/dev/ast/into.h +++ b/dev/ast/into.h @@ -1,6 +1,7 @@ #pragma once #include "../functional/cxx_type_traits_polyfill.h" +#include "../table_reference.h" namespace sqlite_orm { namespace internal { @@ -20,4 +21,11 @@ SQLITE_ORM_EXPORT namespace sqlite_orm { internal::into_t into() { return {}; } + +#ifdef SQLITE_ORM_WITH_CPP20_ALIASES + template + auto into() { + return into>(); + } +#endif } diff --git a/dev/conditions.h b/dev/conditions.h index 24ae7446c..f70e5797f 100644 --- a/dev/conditions.h +++ b/dev/conditions.h @@ -912,11 +912,25 @@ SQLITE_ORM_EXPORT namespace sqlite_orm { return {}; } +#ifdef SQLITE_ORM_WITH_CPP20_ALIASES + template + auto cross_join() { + return cross_join>(); + } +#endif + template internal::natural_join_t natural_join() { return {}; } +#ifdef SQLITE_ORM_WITH_CPP20_ALIASES + template + auto natural_join() { + return natural_join>(); + } +#endif + template internal::left_join_t left_join(O o) { return {std::move(o)}; diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 3eb06ad4a..ea933b2f4 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -2640,7 +2640,13 @@ namespace sqlite_orm { return {}; } - template + template + [[nodiscard]] consteval auto for_() const { + using T = auto_decay_table_ref_t; + return recordset_alias{}; + } + + template [[nodiscard]] consteval auto for_() const { using T = std::remove_const_t; return recordset_alias{}; @@ -6053,11 +6059,25 @@ SQLITE_ORM_EXPORT namespace sqlite_orm { return {}; } +#ifdef SQLITE_ORM_WITH_CPP20_ALIASES + template + auto cross_join() { + return cross_join>(); + } +#endif + template internal::natural_join_t natural_join() { return {}; } +#ifdef SQLITE_ORM_WITH_CPP20_ALIASES + template + auto natural_join() { + return natural_join>(); + } +#endif + template internal::left_join_t left_join(O o) { return {std::move(o)}; @@ -6342,6 +6362,8 @@ SQLITE_ORM_EXPORT namespace sqlite_orm { // #include "../functional/cxx_type_traits_polyfill.h" +// #include "../table_reference.h" + namespace sqlite_orm { namespace internal { @@ -6360,6 +6382,13 @@ SQLITE_ORM_EXPORT namespace sqlite_orm { internal::into_t into() { return {}; } + +#ifdef SQLITE_ORM_WITH_CPP20_ALIASES + template + auto into() { + return into>(); + } +#endif } namespace sqlite_orm { diff --git a/tests/static_tests/alias.cpp b/tests/static_tests/alias.cpp index 11b611292..5c6d72e31 100644 --- a/tests/static_tests/alias.cpp +++ b/tests/static_tests/alias.cpp @@ -107,6 +107,8 @@ TEST_CASE("aliases") { SECTION("table alias expressions") { constexpr auto derived_user = c(); constexpr auto d_alias = "d"_alias.for_(); + constexpr auto tableref_alias = "d"_alias.for_(); + STATIC_REQUIRE(std::is_same_v); using d_alias_type = decltype("d"_alias.for_()); runTest>(from()); runTest>(asterisk()); diff --git a/tests/static_tests/column_pointer.cpp b/tests/static_tests/column_pointer.cpp index f98ea0669..05c92f090 100644 --- a/tests/static_tests/column_pointer.cpp +++ b/tests/static_tests/column_pointer.cpp @@ -149,6 +149,7 @@ TEST_CASE("column pointers") { SECTION("table reference expressions") { runTest>(make_table("derived_user")); runTest>(from()); + runTest>(into()); runTest>(asterisk()); runTest>(object()); runTest>(count()); @@ -162,6 +163,8 @@ TEST_CASE("column pointers") { left_outer_join(using_(derived_user->*&DerivedUser::id))); runTest>>( inner_join(using_(derived_user->*&DerivedUser::id))); + runTest>(cross_join()); + runTest>(natural_join()); STATIC_REQUIRE(refers_to_recordset_callable); STATIC_REQUIRE(refers_to_table_callable);