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

Make MockDb a bit more talkative for tests

This commit is contained in:
rbock 2015-01-11 16:12:39 +01:00
parent b4f62a5eb6
commit c4ee228f12
2 changed files with 13 additions and 14 deletions

View File

@ -27,6 +27,7 @@
#define SQLPP_MOCK_DB_H #define SQLPP_MOCK_DB_H
#include <sstream> #include <sstream>
#include <iostream>
#include <sqlpp11/serializer_context.h> #include <sqlpp11/serializer_context.h>
#include <sqlpp11/connection.h> #include <sqlpp11/connection.h>
@ -133,6 +134,7 @@ struct MockDbT: public sqlpp::connection
{ {
_serializer_context_t context; _serializer_context_t context;
::sqlpp::serialize(x, context); ::sqlpp::serialize(x, context);
std::cout << "Running execute call with\n" << context.str() << std::endl;
} }
template<typename Insert> template<typename Insert>
@ -140,6 +142,7 @@ struct MockDbT: public sqlpp::connection
{ {
_serializer_context_t context; _serializer_context_t context;
::sqlpp::serialize(x, context); ::sqlpp::serialize(x, context);
std::cout << "Running insert call with\n" << context.str() << std::endl;
return 0; return 0;
} }
@ -148,6 +151,7 @@ struct MockDbT: public sqlpp::connection
{ {
_serializer_context_t context; _serializer_context_t context;
::sqlpp::serialize(x, context); ::sqlpp::serialize(x, context);
std::cout << "Running update call with\n" << context.str() << std::endl;
return 0; return 0;
} }
@ -156,6 +160,7 @@ struct MockDbT: public sqlpp::connection
{ {
_serializer_context_t context; _serializer_context_t context;
::sqlpp::serialize(x, context); ::sqlpp::serialize(x, context);
std::cout << "Running remove call with\n" << context.str() << std::endl;
return 0; return 0;
} }
@ -164,6 +169,7 @@ struct MockDbT: public sqlpp::connection
{ {
_serializer_context_t context; _serializer_context_t context;
::sqlpp::serialize(x, context); ::sqlpp::serialize(x, context);
std::cout << "Running select call with\n" << context.str() << std::endl;
return {}; return {};
} }
@ -195,6 +201,7 @@ struct MockDbT: public sqlpp::connection
{ {
_serializer_context_t context; _serializer_context_t context;
::sqlpp::serialize(x, context); ::sqlpp::serialize(x, context);
std::cout << "Running prepare execute call with\n" << context.str() << std::endl;
return nullptr; return nullptr;
} }
@ -203,6 +210,7 @@ struct MockDbT: public sqlpp::connection
{ {
_serializer_context_t context; _serializer_context_t context;
::sqlpp::serialize(x, context); ::sqlpp::serialize(x, context);
std::cout << "Running prepare insert call with\n" << context.str() << std::endl;
return nullptr; return nullptr;
} }
@ -222,6 +230,7 @@ struct MockDbT: public sqlpp::connection
{ {
_serializer_context_t context; _serializer_context_t context;
::sqlpp::serialize(x, context); ::sqlpp::serialize(x, context);
std::cout << "Running prepare select call with\n" << context.str() << std::endl;
return nullptr; return nullptr;
} }

View File

@ -37,22 +37,12 @@ int main()
test::TabBar t; test::TabBar t;
test::TabFoo f; test::TabFoo f;
auto u = select(t.alpha).from(t).union_distinct(select(f.epsilon).from(f)); db(select(t.alpha).from(t).union_distinct(select(f.epsilon).from(f)));
db(select(t.alpha).from(t).union_all(select(f.epsilon).from(f)));
printer.reset(); auto u = select(t.alpha).from(t).union_all(select(f.epsilon).from(f)).as(sqlpp::alias::u);
std::cerr << serialize(u, printer).str() << std::endl;
auto ua = select(t.alpha).from(t).union_all(select(f.epsilon).from(f)).as(sqlpp::alias::u); db(select(all_of(u)).from(u).union_all(select(t.delta).from(t)));
printer.reset();
std::cerr << serialize(ua, printer).str() << std::endl;
auto uu = select(all_of(ua)).from(ua).union_all(select(t.delta).from(t));
printer.reset();
std::cerr << serialize(uu, printer).str() << std::endl;
db(u);
return 0; return 0;
} }