0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 12:51:13 +08:00

Fixed a few broken tests

This commit is contained in:
Roland Bock 2024-09-01 11:15:29 +02:00
parent 125a372c32
commit 3c36b1d025
8 changed files with 25 additions and 23 deletions

View File

@ -51,7 +51,7 @@ int From(int, char* [])
SQLPP_COMPARE(from(foo.inner_join(bar).on(foo.doubleN > bar.id)), SQLPP_COMPARE(from(foo.inner_join(bar).on(foo.doubleN > bar.id)),
" FROM tab_foo INNER JOIN tab_bar ON tab_foo.double_n > tab_bar.id"); " FROM tab_foo INNER JOIN tab_bar ON tab_foo.double_n > tab_bar.id");
SQLPP_COMPARE(from(foo.full_outer_join(bar).on(foo.doubleN > bar.id)), SQLPP_COMPARE(from(foo.full_outer_join(bar).on(foo.doubleN > bar.id)),
" FROM tab_foo OUTER JOIN tab_bar ON tab_foo.double_n > tab_bar.id"); " FROM tab_foo FULL OUTER JOIN tab_bar ON tab_foo.double_n > tab_bar.id");
SQLPP_COMPARE(from(foo.left_outer_join(bar).on(foo.doubleN > bar.id)), SQLPP_COMPARE(from(foo.left_outer_join(bar).on(foo.doubleN > bar.id)),
" FROM tab_foo LEFT OUTER JOIN tab_bar ON tab_foo.double_n > tab_bar.id"); " 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)), SQLPP_COMPARE(from(foo.right_outer_join(bar).on(foo.doubleN > bar.id)),

View File

@ -61,7 +61,7 @@ int SelectColumns(int, char*[])
// Optional column manually // Optional column manually
SQLPP_COMPARE(select(dynamic(true, bar.id)), "SELECT tab_bar.id"); SQLPP_COMPARE(select(dynamic(true, bar.id)), "SELECT tab_bar.id");
SQLPP_COMPARE(select(dynamic(false, bar.id)), "SELECT NULL as id"); SQLPP_COMPARE(select(dynamic(false, bar.id)), "SELECT NULL AS id");
#warning: add more optional column tests #warning: add more optional column tests

View File

@ -64,7 +64,8 @@ int main(int, char* [])
// Single declared column // Single declared column
SQLPP_COMPARE(group_by(declare_group_by_column(val)), " GROUP BY 17"); SQLPP_COMPARE(group_by(declare_group_by_column(val)), " GROUP BY 17");
SQLPP_COMPARE(group_by(declare_group_by_column(foo.id + 17)), " GROUP BY tab_foo.id + 17"); #warning: Do we really want these extra parentheses?
SQLPP_COMPARE(group_by(declare_group_by_column(foo.id + 17)), " GROUP BY (tab_foo.id + 17)");
// Mixed declared column // Mixed declared column
SQLPP_COMPARE(group_by(foo.id, declare_group_by_column(val)), " GROUP BY tab_foo.id, 17"); SQLPP_COMPARE(group_by(foo.id, declare_group_by_column(val)), " GROUP BY tab_foo.id, 17");

View File

@ -40,19 +40,19 @@ void test_group_by()
using J = decltype(foo.join(bar).on(foo.id == bar.id)); using J = decltype(foo.join(bar).on(foo.id == bar.id));
static_assert(sqlpp::is_table<J>::value, ""); static_assert(sqlpp::is_table<J>::value, "");
static_assert( static_assert(
std::is_same<sqlpp::provided_tables_of_t<J>, sqlpp::detail::type_set<test::TabFoo, test::TabBar>>::value, ""); std::is_same<sqlpp::provided_tables_of_t<J>, sqlpp::detail::type_vector<sqlpp::table_t<test::TabFoo_>, sqlpp::table_t<test::TabBar_>>>::value, "");
static_assert( static_assert(
std::is_same<sqlpp::provided_optional_tables_of_t<J>, sqlpp::detail::type_set<>>::value, ""); std::is_same<sqlpp::provided_optional_tables_of_t<J>, sqlpp::detail::type_vector<>>::value, "");
#warning: test the provided dynamic tables of? #warning: test the provided dynamic tables of?
} }
{ {
using J = decltype(foo.outer_join(bar).on(foo.id == bar.id)); using J = decltype(foo.full_outer_join(bar).on(foo.id == bar.id));
static_assert(sqlpp::is_table<J>::value, ""); static_assert(sqlpp::is_table<J>::value, "");
static_assert( static_assert(
std::is_same<sqlpp::provided_tables_of_t<J>, sqlpp::detail::type_set<test::TabFoo, test::TabBar>>::value, ""); std::is_same<sqlpp::provided_tables_of_t<J>, sqlpp::detail::type_vector<sqlpp::table_t<test::TabFoo_>, sqlpp::table_t<test::TabBar_>>>::value, "");
static_assert( static_assert(
std::is_same<sqlpp::provided_optional_tables_of_t<J>, sqlpp::detail::type_set<test::TabFoo, test::TabBar>>::value, ""); std::is_same<sqlpp::provided_optional_tables_of_t<J>, sqlpp::detail::type_vector<sqlpp::table_t<test::TabFoo_>, sqlpp::table_t<test::TabBar_>>>::value, "");
#warning: test the provided dynamic tables of? #warning: test the provided dynamic tables of?
} }
@ -61,15 +61,17 @@ void test_group_by()
using J = decltype(foo.join(dynamic(true, bar)).on(foo.id == bar.id)); using J = decltype(foo.join(dynamic(true, bar)).on(foo.id == bar.id));
static_assert(sqlpp::is_table<J>::value, ""); static_assert(sqlpp::is_table<J>::value, "");
static_assert( static_assert(
std::is_same<sqlpp::provided_tables_of_t<J>, sqlpp::detail::type_set<test::TabFoo, test::TabBar>>::value, ""); std::is_same<sqlpp::provided_tables_of_t<J>, sqlpp::detail::type_vector<test::TabFoo, test::TabBar>>::value, "");
#warning: OUTER is the wrong term. In a left-outer join, the *right* table is the one with optional rows. #warning: OUTER is the wrong term. In a left-outer join, the *right* table is the one with optional rows.
static_assert( static_assert(
std::is_same<sqlpp::provided_optional_tables_of_t<J>, sqlpp::detail::type_set<>>::value, ""); std::is_same<sqlpp::provided_optional_tables_of_t<J>, sqlpp::detail::type_vector<>>::value, "");
#warning: test the provided dynamic tables of? #warning: test the provided dynamic tables of?
} }
#warning: Need to add tests all join types! #warning: Need to add tests all join types!
#warning: Need to add tests with table_as
#warning: Need to add tests with verbatim tables
#warning: Need to add tests with 3 tables #warning: Need to add tests with 3 tables
#warning: Need to add tests with CTEs #warning: Need to add tests with CTEs

View File

@ -27,7 +27,6 @@
#include "Sample.h" #include "Sample.h"
#include "MockDb.h" #include "MockDb.h"
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
#include <sqlpp11/core/query/query/custom_query.h>
#include "../../include/test_helpers.h" #include "../../include/test_helpers.h"
namespace namespace