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:
parent
36d3d30254
commit
91b7b34557
@ -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,29 +115,34 @@ int Sample(int, char*[])
|
||||
db(dynin);
|
||||
|
||||
// remove
|
||||
db(remove_from(tab).where(tab.alpha == tab.alpha + 3));
|
||||
|
||||
std::cerr << "+++++++++++++++++++++++++++" << std::endl;
|
||||
for (const auto& row : db(select(all_of(tab)).from(tab).unconditionally()))
|
||||
{
|
||||
std::cerr << __LINE__ << " row.beta: " << row.beta << std::endl;
|
||||
}
|
||||
std::cerr << "+++++++++++++++++++++++++++" << std::endl;
|
||||
decltype(db(select(all_of(tab)).from(tab).unconditionally())) result;
|
||||
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;
|
||||
db(remove_from(tab).where(tab.alpha == tab.alpha + 3));
|
||||
|
||||
auto tx = start_transaction(db);
|
||||
if (const auto& row =
|
||||
*db(select(all_of(tab), select(max(tab.alpha)).from(tab)).from(tab).unconditionally()).begin())
|
||||
{
|
||||
int a = row.alpha;
|
||||
int m = row.max;
|
||||
std::cerr << __LINE__ << " row.alpha: " << a << ", row.max: " << m << std::endl;
|
||||
std::cerr << "+++++++++++++++++++++++++++" << std::endl;
|
||||
for (const auto& row : db(select(all_of(tab)).from(tab).unconditionally()))
|
||||
{
|
||||
std::cerr << __LINE__ << " row.beta: " << row.beta << std::endl;
|
||||
}
|
||||
std::cerr << "+++++++++++++++++++++++++++" << std::endl;
|
||||
decltype(db(select(all_of(tab)).from(tab).unconditionally())) result;
|
||||
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;
|
||||
}
|
||||
|
||||
// transaction
|
||||
{
|
||||
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();
|
||||
}
|
||||
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;
|
||||
|
@ -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,22 +147,27 @@ 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())
|
||||
{
|
||||
int a = row.alpha;
|
||||
int m = row.max;
|
||||
std::cerr << "-----------------------------" << a << ", " << m << std::endl;
|
||||
}
|
||||
tx.commit();
|
||||
|
||||
// transaction
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user