0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Fix broken test code, see #400

This commit is contained in:
Roland Bock 2021-12-11 19:31:25 +01:00
parent 36d3d30254
commit 91b7b34557
2 changed files with 40 additions and 35 deletions

View File

@ -31,9 +31,6 @@
#include <iostream>
#include <vector>
SQLPP_ALIAS_PROVIDER(left)
SQLPP_ALIAS_PROVIDER(right)
namespace mysql = sqlpp::mysql;
int Sample(int, char*[])
{
@ -118,6 +115,7 @@ int Sample(int, char*[])
db(dynin);
// remove
{
db(remove_from(tab).where(tab.alpha == tab.alpha + 3));
std::cerr << "+++++++++++++++++++++++++++" << std::endl;
@ -131,16 +129,20 @@ int Sample(int, char*[])
std::cerr << "Accessing a field directly from the result (using the current row): " << result.begin()->alpha
<< std::endl;
std::cerr << "Can do that again, no problem: " << result.begin()->alpha << std::endl;
}
auto tx = start_transaction(db);
if (const auto& row =
*db(select(all_of(tab), select(max(tab.alpha)).from(tab)).from(tab).unconditionally()).begin())
// transaction
{
int a = row.alpha;
int m = row.max;
auto tx = start_transaction(db);
auto result = db(select(all_of(tab), select(max(tab.alpha)).from(tab)).from(tab).unconditionally());
if (const auto& row = *result.begin())
{
long a = row.alpha;
long m = row.max;
std::cerr << __LINE__ << " row.alpha: " << a << ", row.max: " << m << std::endl;
}
tx.commit();
}
TabFoo foo;
for (const auto& row : db(select(tab.alpha).from(tab.join(foo).on(tab.alpha == foo.omega)).unconditionally()))
@ -169,7 +171,7 @@ int Sample(int, char*[])
}
std::cerr << "--------" << std::endl;
ps.params.gamma = "false";
ps.params.gamma = false;
for (const auto& row : db(ps))
{
std::cerr << "bound result: alpha: " << row.alpha << std::endl;

View File

@ -39,8 +39,6 @@
const auto library_raii = sqlpp::mysql::scoped_library_initializer_t{0, nullptr, nullptr};
SQLPP_ALIAS_PROVIDER(left)
namespace sql = sqlpp::mysql;
const auto tab = TabSample{};
@ -149,23 +147,28 @@ int Select(int, char*[])
db(update(tab).set(tab.gamma = false).where(tab.alpha.in(sqlpp::value_list(std::vector<int>{1, 2, 3, 4}))));
// remove
{
db(remove_from(tab).where(tab.alpha == tab.alpha + 3));
auto result = db(select(all_of(tab)).from(tab).unconditionally());
std::cerr << "Accessing a field directly from the result (using the current row): " << result.begin()->alpha
<< std::endl;
std::cerr << "Can do that again, no problem: " << result.begin()->alpha << std::endl;
}
auto tx = start_transaction(db);
if (const auto& row =
*db(select(all_of(tab), select(max(tab.alpha)).from(tab)).from(tab).unconditionally()).begin())
// transaction
{
int a = row.alpha;
int m = row.max;
auto tx = start_transaction(db);
auto result = db(select(all_of(tab), select(max(tab.alpha)).from(tab)).from(tab).unconditionally());
if (const auto& row = *result.begin())
{
long a = row.alpha;
long m = row.max;
std::cerr << "-----------------------------" << a << ", " << m << std::endl;
}
tx.commit();
}
}
catch (const std::exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;