diff --git a/include/sqlpp11/core/basic/column.h b/include/sqlpp11/core/basic/column.h
index 8d92b5e7..4bc13bb9 100644
--- a/include/sqlpp11/core/basic/column.h
+++ b/include/sqlpp11/core/basic/column.h
@@ -121,6 +121,7 @@ namespace sqlpp
{
using T = column_t
;
- return name_to_sql_string(context, name_tag_of_t::name) + "." + name_to_sql_string(context, name_tag_of_t::name);
+ return name_to_sql_string(context, name_tag_of_t::name) + "." +
+ name_to_sql_string(context, name_tag_of_t::name);
}
} // namespace sqlpp
diff --git a/include/sqlpp11/core/basic/enable_join.h b/include/sqlpp11/core/basic/enable_join.h
index 6bbf4410..eb8adfea 100644
--- a/include/sqlpp11/core/basic/enable_join.h
+++ b/include/sqlpp11/core/basic/enable_join.h
@@ -43,6 +43,7 @@ namespace sqlpp
template
auto join(T t) const -> decltype(::sqlpp::join(this->derived(), t))
{
+#warning: move?
return ::sqlpp::join(this->derived(), t);
}
diff --git a/include/sqlpp11/core/basic/join.h b/include/sqlpp11/core/basic/join.h
index 2a71c2b5..a05e1ecf 100644
--- a/include/sqlpp11/core/basic/join.h
+++ b/include/sqlpp11/core/basic/join.h
@@ -187,40 +187,41 @@ namespace sqlpp
// Note: See sqlpp11/core/basic/join_fwd.h for forward declarations including check_join_args.
+#warning: reactivate check_join_args?
template */>
- auto join(Lhs lhs, Rhs rhs) -> pre_join_t
+ auto join(Lhs lhs, Rhs rhs) -> pre_join_t, inner_join_t, table_ref_t>
{
- return {std::move(lhs), std::move(rhs)};
+ return {make_table_ref(std::move(lhs)), make_table_ref(std::move(rhs))};
}
template */>
- auto inner_join(Lhs lhs, Rhs rhs) -> pre_join_t
+ auto inner_join(Lhs lhs, Rhs rhs) -> pre_join_t, inner_join_t, table_ref_t>
{
- return {std::move(lhs), std::move(rhs)};
+ return {make_table_ref(std::move(lhs)), make_table_ref(std::move(rhs))};
}
template */>
- auto left_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t
+ auto left_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t, left_outer_join_t, table_ref_t>
{
- return {std::move(lhs), std::move(rhs)};
+ return {make_table_ref(std::move(lhs)), make_table_ref(std::move(rhs))};
}
template */>
- auto right_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t
+ auto right_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t, right_outer_join_t, table_ref_t>
{
- return {std::move(lhs), std::move(rhs)};
+ return {make_table_ref(std::move(lhs)), make_table_ref(std::move(rhs))};
}
template */>
- auto full_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t
+ auto full_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t, full_outer_join_t, table_ref_t>
{
- return {std::move(lhs), std::move(rhs)};
+ return {make_table_ref(std::move(lhs)), make_table_ref(std::move(rhs))};
}
template */>
- auto cross_join(Lhs lhs, Rhs rhs) -> join_t
+ auto cross_join(Lhs lhs, Rhs rhs) -> join_t, cross_join_t, table_ref_t, unconditional_t>
{
- return {std::move(lhs), std::move(rhs), {}};
+ return {make_table_ref(std::move(lhs)), make_table_ref(std::move(rhs)), {}};
}
} // namespace sqlpp
diff --git a/include/sqlpp11/core/basic/join_fwd.h b/include/sqlpp11/core/basic/join_fwd.h
index ff2c2106..99110e1e 100644
--- a/include/sqlpp11/core/basic/join_fwd.h
+++ b/include/sqlpp11/core/basic/join_fwd.h
@@ -74,21 +74,21 @@ namespace sqlpp
sqlpp::detail::transform_t, make_char_sequence>{})>;
template >
- auto join(Lhs lhs, Rhs rhs) -> pre_join_t;
+ auto join(Lhs lhs, Rhs rhs) -> pre_join_t, inner_join_t, table_ref_t>;
template >
- auto inner_join(Lhs lhs, Rhs rhs) -> pre_join_t;
+ auto inner_join(Lhs lhs, Rhs rhs) -> pre_join_t, inner_join_t, table_ref_t>;
template >
- auto left_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t;
+ auto left_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t, left_outer_join_t, table_ref_t>;
template >
- auto right_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t;
+ auto right_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t, right_outer_join_t, table_ref_t>;
template >
- auto full_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t;
+ auto full_outer_join(Lhs lhs, Rhs rhs) -> pre_join_t, full_outer_join_t, table_ref_t>;
template >
- auto cross_join(Lhs lhs, Rhs rhs) -> join_t;
+ auto cross_join(Lhs lhs, Rhs rhs) -> join_t, cross_join_t, table_ref_t, unconditional_t>;
} // namespace sqlpp
diff --git a/include/sqlpp11/core/basic/table_ref.h b/include/sqlpp11/core/basic/table_ref.h
index afa6287c..98c8d5ff 100644
--- a/include/sqlpp11/core/basic/table_ref.h
+++ b/include/sqlpp11/core/basic/table_ref.h
@@ -45,7 +45,7 @@ namespace sqlpp
using from_table_t = typename from_table_impl::type;
template
- auto table_ref(T t) -> T
+ auto make_table_ref(T t) -> T
{
return t;
}
diff --git a/include/sqlpp11/core/clause/cte.h b/include/sqlpp11/core/clause/cte.h
index 7f195e5f..75e26521 100644
--- a/include/sqlpp11/core/clause/cte.h
+++ b/include/sqlpp11/core/clause/cte.h
@@ -76,6 +76,18 @@ namespace sqlpp
template
struct cte_ref_t;
+ template
+ struct table_ref>
+ {
+ using type = cte_ref_t;
+ };
+
+ template
+ auto make_table_ref(cte_t /* unused */) -> cte_ref_t
+ {
+ return {};
+ }
+
template
auto from_table(cte_t /*unused*/) -> cte_ref_t
{
@@ -97,6 +109,9 @@ namespace sqlpp
using value_type = value_type_of_t;
};
+ template
+ struct name_tag_of> : public name_tag_of{};
+
template
struct make_cte_impl
{
@@ -119,7 +134,7 @@ namespace sqlpp
template
struct cte_base
{
- using type = member_t>>;
+ using type = member_t, cte_column_spec_t>>;
};
template
@@ -262,6 +277,17 @@ namespace sqlpp
template
struct is_table> : public std::true_type{};
+ template
+ struct provided_tables_of>
+ {
+ using type = sqlpp::detail::type_vector>;
+ };
+
+ template
+ struct provided_static_tables_of> : public provided_tables_of>
+ {
+ };
+
template
struct name_tag_of> : public name_tag_of{};
diff --git a/include/sqlpp11/core/type_traits.h b/include/sqlpp11/core/type_traits.h
index 2463988a..ce35576a 100644
--- a/include/sqlpp11/core/type_traits.h
+++ b/include/sqlpp11/core/type_traits.h
@@ -567,6 +567,14 @@ namespace sqlpp
using type = no_context_t;
};
+ template
+ struct table_ref {
+ using type = T;
+ };
+
+ template
+ using table_ref_t = typename table_ref::type;
+
template
struct serializer_context_of_impl>
{
diff --git a/tests/core/serialize/clause/from.cpp b/tests/core/serialize/clause/from.cpp
index 8c635723..f39eb871 100644
--- a/tests/core/serialize/clause/from.cpp
+++ b/tests/core/serialize/clause/from.cpp
@@ -53,8 +53,7 @@ int main()
// CTE
SQLPP_COMPARE(from(x), " FROM x");
- x.join(foo).on(x.id == foo.id);
- //SQLPP_COMPARE(from(x.join(foo).on(x.id == foo.id)), " FROM x");
+ SQLPP_COMPARE(from(x.join(foo).on(x.id == foo.id)), " FROM x INNER JOIN tab_foo ON x.id = tab_foo.id");
#warning add tests for dynamic joins