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

Merge tag '0.55' into develop

Multiple new data types (ddl2cpp) and a couple of small fixes
This commit is contained in:
rbock 2018-06-01 09:59:35 +02:00
commit 517f31348e
17 changed files with 59 additions and 60 deletions

View File

@ -53,5 +53,5 @@ namespace sqlpp
concat_t<Column, wrap_operand_t<T>>{*static_cast<const Column*>(this), rhs{t}}};
}
};
}
} // namespace sqlpp
#endif

View File

@ -45,5 +45,5 @@ namespace sqlpp
using blob = blob;
using mediumblob = blob;
}
} // namespace sqlpp
#endif

View File

@ -90,5 +90,5 @@ namespace sqlpp
return context;
}
};
}
} // namespace sqlpp
#endif

View File

@ -49,5 +49,5 @@ namespace sqlpp
target._bind_blob_parameter(index, &_value, _is_null);
}
};
}
} // namespace sqlpp
#endif

View File

@ -48,7 +48,7 @@ namespace sqlpp
{
target._bind_blob_result(index, &blob, &len);
if (blob)
this->_value.assign(blob, blob+len);
this->_value.assign(blob, blob + len);
else
this->_value.clear();
this->_is_null = (blob == nullptr);
@ -59,7 +59,7 @@ namespace sqlpp
{
target._post_bind_blob_result(index, &blob, &len);
if (blob)
this->_value.assign(blob, blob+len);
this->_value.assign(blob, blob + len);
else
this->_value.clear();
this->_is_null = (blob == nullptr);
@ -79,5 +79,5 @@ namespace sqlpp
return os << e.value();
}
}
}
} // namespace sqlpp
#endif

View File

@ -47,5 +47,5 @@ namespace sqlpp
{
using type = blob_operand;
};
}
} // namespace sqlpp
#endif

View File

@ -39,6 +39,6 @@ namespace sqlpp
};
template <typename T, typename Defer>
using return_type_like_t = typename return_type_like<T, Defer>::type;
}
} // namespace sqlpp
#endif

View File

@ -124,7 +124,7 @@ namespace sqlpp
struct insert_list_data_t
{
insert_list_data_t(std::tuple<Assignments...> assignments)
: _assignments(assignments), _columns( columns_from_tuple(assignments) ), _values( values_from_tuple(assignments) )
: _assignments(assignments), _columns(columns_from_tuple(assignments)), _values(values_from_tuple(assignments))
{
}
@ -140,30 +140,34 @@ namespace sqlpp
std::tuple<rhs_t<Assignments>...> _values;
interpretable_list_t<Database> _dynamic_columns;
interpretable_list_t<Database> _dynamic_values;
private:
template< size_t... Indexes >
auto columns_from_tuple( detail::index_sequence<Indexes... >, std::tuple<Assignments ...> assignments ) -> decltype (_columns)
template <size_t... Indexes>
auto columns_from_tuple(detail::index_sequence<Indexes...>, std::tuple<Assignments...> assignments)
-> decltype(_columns)
{
(void) assignments;
return decltype(_columns)(std::get<Indexes>(assignments)._lhs...);
(void)assignments;
return decltype(_columns)(std::get<Indexes>(assignments)._lhs...);
}
auto columns_from_tuple(std::tuple<Assignments ...> assignments) -> decltype (_columns) {
const auto seq = detail::make_index_sequence<sizeof... (Assignments)>{};
return columns_from_tuple(seq, assignments);
auto columns_from_tuple(std::tuple<Assignments...> assignments) -> decltype(_columns)
{
const auto seq = detail::make_index_sequence<sizeof...(Assignments)>{};
return columns_from_tuple(seq, assignments);
}
template< size_t... Indexes >
auto values_from_tuple( detail::index_sequence<Indexes... >, std::tuple<Assignments ...> assignments ) -> decltype(_values)
template <size_t... Indexes>
auto values_from_tuple(detail::index_sequence<Indexes...>, std::tuple<Assignments...> assignments)
-> decltype(_values)
{
(void) assignments;
(void)assignments;
return decltype(_values)(std::get<Indexes>(assignments)._rhs...);
}
auto values_from_tuple( std::tuple<Assignments ...> assignments ) -> decltype(_values)
auto values_from_tuple(std::tuple<Assignments...> assignments) -> decltype(_values)
{
const auto seq = detail::make_index_sequence<sizeof... (Assignments)>{};
return values_from_tuple(seq, assignments);
const auto seq = detail::make_index_sequence<sizeof...(Assignments)>{};
return values_from_tuple(seq, assignments);
}
};
@ -589,7 +593,7 @@ namespace sqlpp
auto _set_impl(Check, Assignments... assignments) const -> inconsistent<Check>;
template <typename Database, typename... Assignments>
auto _set_impl(consistent_t /*unused*/,std::tuple<Assignments...> assignments) const
auto _set_impl(consistent_t /*unused*/, std::tuple<Assignments...> assignments) const
-> _new_statement_t<consistent_t, insert_list_t<Database, Assignments...>>
{
return {static_cast<const derived_statement_t<Policies>&>(*this),

View File

@ -38,7 +38,7 @@ namespace sqlpp
template <typename Database, typename... Assignments>
struct update_list_data_t
{
update_list_data_t(std::tuple<Assignments ...> assignments ) : _assignments(assignments)
update_list_data_t(std::tuple<Assignments...> assignments) : _assignments(assignments)
{
}

View File

@ -74,6 +74,14 @@ def repl_func_for_args(m):
else:
return m.group(1) + m.group(2).upper()
def toClassName(s):
return re.sub("(^|\s|[_0-9])(\S)", repl_func, s)
def toMemberName(s):
return re.sub("(\s|_|[0-9])(\S)", repl_func, s)
def setArgumentBool(s, bool_value):
first_lower = lambda s: s[:1].lower() + s[1:] if s else '' # http://stackoverflow.com/a/3847369/5006740
var_name = first_lower(re.sub("(\s|-|[0-9])(\S)", repl_func_for_args, s))

View File

@ -50,9 +50,9 @@ namespace
{
return std::vector<std::uint8_t>(s.begin(), s.end());
}
}
} // namespace
int Blob(int, char* [])
int Blob(int, char*[])
{
const auto foo = test::TabFoo{};
// const auto bar = test::TabBar{};

View File

@ -30,7 +30,7 @@
#include <sqlpp11/functions.h>
#include <sqlpp11/insert.h>
int Insert(int, char* [])
int Insert(int, char*[])
{
MockDb db = {};
MockDb::_serializer_context_t printer = {};
@ -71,9 +71,7 @@ int Insert(int, char* [])
db(multi_insert);
auto values=[&t](){
return std::make_tuple(t.gamma = true, t.delta = sqlpp::tvin(0));
};
auto values = [&t]() { return std::make_tuple(t.gamma = true, t.delta = sqlpp::tvin(0)); };
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")));
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::null));

View File

@ -292,7 +292,6 @@ struct MockDbT : public sqlpp::connection
using MockDb = MockDbT<false>;
using EnforceDb = MockDbT<true>;
struct MockSizeDb : public sqlpp::connection
{
using _traits = MockDb::_traits;
@ -323,7 +322,10 @@ struct MockSizeDb : public sqlpp::connection
class result_t : public MockDb::result_t
{
public:
size_t size() const { return 0; }
size_t size() const
{
return 0;
}
};
// Directly executed statements start here
@ -464,7 +466,7 @@ struct MockSizeDb : public sqlpp::connection
void start_transaction()
{
_mock_data._last_isolation_level = _mock_data._default_isolation_level;
_mock_data._last_isolation_level = _mock_data._default_isolation_level;
}
void start_transaction(sqlpp::isolation_level level)

View File

@ -68,7 +68,7 @@ SQLPP_DECLARE_TABLE(
)
// clang-format on
int Ppgen(int, char* [])
int Ppgen(int, char*[])
{
MockDb db{};
const auto p = tab_person::tab_person{};
@ -79,24 +79,13 @@ int Ppgen(int, char* [])
db(insert_into(f).default_values());
auto i = insert_into(p).columns(p.name, p.feature, p.age, p.level);
i.values.add(p.name = "Roland"
, p.feature = 1
, p.age = static_cast<unsigned int>(32)
, p.level = 3.14);
i.values.add(p.name = "Zaphod"
, p.feature = sqlpp::default_value
, p.age = static_cast<unsigned int>(16)
, p.level = 3.14*2);
i.values.add(p.name = "Roland", p.feature = 1, p.age = static_cast<unsigned int>(32), p.level = 3.14);
i.values.add(p.name = "Zaphod", p.feature = sqlpp::default_value, p.age = static_cast<unsigned int>(16),
p.level = 3.14 * 2);
db(i);
auto pi = db.prepare(
insert_into(p).set(
p.name = parameter(f.name)
,p.feature = parameter(p.feature)
,p.age = parameter(p.age)
,p.level = parameter(p.level)
)
);
auto pi = db.prepare(insert_into(p).set(p.name = parameter(f.name), p.feature = parameter(p.feature),
p.age = parameter(p.age), p.level = parameter(p.level)));
pi.params.name = "likes java";
pi.params.feature = 2;
pi.params.age = 21;

View File

@ -119,7 +119,7 @@ namespace test
};
using _traits = sqlpp::make_traits<sqlpp::blob, sqlpp::tag::can_be_null>;
};
}
} // namespace TabFoo_
struct TabFoo : sqlpp::table_t<TabFoo, TabFoo_::Delta, TabFoo_::Epsilon, TabFoo_::Omega, TabFoo_::Psi, TabFoo_::Book>
{
@ -233,7 +233,7 @@ namespace test
};
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::can_be_null>;
};
}
} // namespace TabBar_
struct TabBar : sqlpp::table_t<TabBar, TabBar_::Alpha, TabBar_::Beta, TabBar_::Gamma, TabBar_::Delta>
{
@ -326,7 +326,7 @@ namespace test
};
using _traits = sqlpp::make_traits<sqlpp::time_of_day, sqlpp::tag::can_be_null>;
};
}
} // namespace TabDateTime_
struct TabDateTime
: sqlpp::table_t<TabDateTime, TabDateTime_::ColDayPoint, TabDateTime_::ColTimePoint, TabDateTime_::ColTimeOfDay>
@ -350,5 +350,5 @@ namespace test
};
};
};
}
} // namespace test
#endif

View File

@ -29,7 +29,7 @@
#include <iostream>
#include <sqlpp11/sqlpp11.h>
int Update(int, char* [])
int Update(int, char*[])
{
MockDb db;
MockDb::_serializer_context_t printer = {};
@ -63,9 +63,7 @@ int Update(int, char* [])
db(u);
auto values=[&t](){
return std::make_tuple(t.delta += t.alpha, t.beta = "no cake this time");
};
auto values = [&t]() { return std::make_tuple(t.delta += t.alpha, t.beta = "no cake this time"); };
db(update(t).set(t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")).unconditionally());
db(update(t).set(t.delta = sqlpp::null).unconditionally());

View File

@ -29,7 +29,7 @@
#include <sqlpp11/alias_provider.h>
#include <iostream>
int With(int, char* [])
int With(int, char*[])
{
MockDb db;
MockDb::_serializer_context_t printer = {};