mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-04 20:20:59 -06:00
Can compile (very simple) custom queries and selects
This commit is contained in:
@@ -56,6 +56,17 @@ namespace sqlpp
|
||||
return static_cast<const _statement_t&>(*this);
|
||||
}
|
||||
|
||||
// Execute
|
||||
template<typename Db, typename Composite>
|
||||
auto _run(Db& db, const Composite& composite) const
|
||||
-> decltype(db.insert(composite))
|
||||
{
|
||||
Composite::_check_consistency();
|
||||
static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead");
|
||||
|
||||
return db.insert(composite);
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
auto _run(Db& db) const -> decltype(db.insert(this->_get_statement()))
|
||||
{
|
||||
@@ -65,14 +76,24 @@ namespace sqlpp
|
||||
return db.insert(_get_statement());
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_insert_t<Db, _statement_t>
|
||||
{
|
||||
_statement_t::_check_consistency();
|
||||
// Prepare
|
||||
template<typename Db, typename Composite>
|
||||
auto _prepare(Db& db, const Composite& composite) const
|
||||
-> prepared_insert_t<Db, Composite>
|
||||
{
|
||||
Composite::_check_consistency();
|
||||
|
||||
return {{}, db.prepare_insert(_get_statement())};
|
||||
}
|
||||
return {{}, db.prepare_insert(composite)};
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_insert_t<Db, _statement_t>
|
||||
{
|
||||
_statement_t::_check_consistency();
|
||||
|
||||
return {{}, db.prepare_insert(_get_statement())};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user