0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

pass table and not table spec to column

This is important for table aliases which currently report
provided_tables_of and required_tables_of as table_t<Alias> only.

After this CL, they use table_alias_t<Alias, Spec>>
This commit is contained in:
Roland Bock 2024-09-01 10:32:13 +02:00
parent 454deace20
commit 33a40b6351
6 changed files with 10 additions and 8 deletions

View File

@ -110,7 +110,7 @@ namespace sqlpp
template<typename Table, typename ColumnSpec>
struct required_tables_of<column_t<Table, ColumnSpec>>
{
using type = detail::type_vector<table_t<Table>>;
using type = detail::type_vector<Table>;
};
template <typename Table, typename ColumnSpec>

View File

@ -37,7 +37,7 @@
namespace sqlpp
{
template <typename TableSpec>
struct table_t : public TableSpec::_table_columns<TableSpec>, public enable_join<table_t<TableSpec>>
struct table_t : public TableSpec::_table_columns<table_t<TableSpec>>, public enable_join<table_t<TableSpec>>
{
using _traits = make_traits<no_value_t, tag::is_raw_table>;

View File

@ -36,7 +36,7 @@
namespace sqlpp
{
template <typename AliasProvider, typename TableSpec>
struct table_alias_t : public TableSpec::_table_columns<AliasProvider>,
struct table_alias_t : public TableSpec::_table_columns<table_alias_t<AliasProvider, TableSpec>>,
public enable_join<table_alias_t<AliasProvider, TableSpec>>
{
using _nodes = detail::type_vector<>;
@ -58,8 +58,7 @@ namespace sqlpp
template <typename AliasProvider, typename TableSpec>
struct provided_tables_of<table_alias_t<AliasProvider, TableSpec>>
{
#warning: This is a bit wonky... Maybe we should actually pass the table and not the table_spec into the column template.
using type = sqlpp::detail::type_vector<table_t<AliasProvider>>;
using type = sqlpp::detail::type_vector<table_alias_t<AliasProvider, TableSpec>>;
};
template <typename AliasProvider, typename TableSpec>

View File

@ -728,7 +728,7 @@ def createHeader():
if not columnHasDefault:
if tableRequiredInsertColumns:
tableRequiredInsertColumns += ","
tableRequiredInsertColumns += "\n sqlpp::column_t<" + tableSpec + ", " + columnClass + ">";
tableRequiredInsertColumns += "\n sqlpp::column_t<sqlpp::table_t<" + tableSpec + ">, " + columnClass + ">";
print(" SQLPP_NAME_TAG_FOR_SQL_AND_CPP("
+ escape_if_reserved(sqlTableName) + ", " + tableMember + ");"
, file=header)

View File

@ -56,9 +56,12 @@ int From(int, char* [])
" FROM tab_foo LEFT OUTER JOIN tab_bar ON tab_foo.double_n > tab_bar.id");
SQLPP_COMPARE(from(foo.right_outer_join(bar).on(foo.doubleN > bar.id)),
" FROM tab_foo RIGHT OUTER JOIN tab_bar ON tab_foo.double_n > tab_bar.id");
sqlpp::provided_tables_of_t<decltype(aFoo.cross_join(bFoo))>::hansi;
sqlpp::required_tables_of_t<decltype(aFoo.doubleN > bFoo.doubleN)>::hansi;
#warning: reactivate
/*
SQLPP_COMPARE(from(aFoo.join(bFoo).on(aFoo.doubleN > bFoo.doubleN)),
" FROM tab_foo AS a INNER JOIN tab_foo AS b ON a.double_n > b.double_n");
/*
SQLPP_COMPARE(from(aFoo.join(bFoo).on(aFoo.doubleN > bFoo.doubleN).join(cFoo).on(bFoo.doubleN > cFoo.doubleN)),
" FROM tab_foo AS a INNER JOIN tab_foo AS b ON a.double_n > b.double_n INNER JOIN tab_foo AS c ON b.double_n > c.double_n");
SQLPP_COMPARE(from(foo.join(bar).unconditionally()), " FROM tab_foo INNER JOIN tab_bar");

View File

@ -102,7 +102,7 @@ namespace test
BoolNn,
IntN>;
using _required_insert_columns = sqlpp::detail::type_set<
sqlpp::column_t<TabBar_, BoolNn>>;
sqlpp::column_t<sqlpp::table_t<TabBar_>, BoolNn>>;
};
using TabBar = ::sqlpp::table_t<TabBar_>;