mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Make MockDb a bit more talkative for tests
This commit is contained in:
parent
b4f62a5eb6
commit
c4ee228f12
@ -27,6 +27,7 @@
|
||||
#define SQLPP_MOCK_DB_H
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <sqlpp11/serializer_context.h>
|
||||
#include <sqlpp11/connection.h>
|
||||
|
||||
@ -133,6 +134,7 @@ struct MockDbT: public sqlpp::connection
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running execute call with\n" << context.str() << std::endl;
|
||||
}
|
||||
|
||||
template<typename Insert>
|
||||
@ -140,6 +142,7 @@ struct MockDbT: public sqlpp::connection
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running insert call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -148,6 +151,7 @@ struct MockDbT: public sqlpp::connection
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running update call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -156,6 +160,7 @@ struct MockDbT: public sqlpp::connection
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running remove call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -164,6 +169,7 @@ struct MockDbT: public sqlpp::connection
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running select call with\n" << context.str() << std::endl;
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -195,6 +201,7 @@ struct MockDbT: public sqlpp::connection
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare execute call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -203,6 +210,7 @@ struct MockDbT: public sqlpp::connection
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare insert call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -222,6 +230,7 @@ struct MockDbT: public sqlpp::connection
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare select call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -37,22 +37,12 @@ int main()
|
||||
test::TabBar t;
|
||||
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();
|
||||
std::cerr << serialize(u, printer).str() << std::endl;
|
||||
auto u = select(t.alpha).from(t).union_all(select(f.epsilon).from(f)).as(sqlpp::alias::u);
|
||||
|
||||
auto ua = select(t.alpha).from(t).union_all(select(f.epsilon).from(f)).as(sqlpp::alias::u);
|
||||
|
||||
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);
|
||||
db(select(all_of(u)).from(u).union_all(select(t.delta).from(t)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user