0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Demonstrate insert with select (#539)

This commit is contained in:
Roland Bock 2023-11-03 07:23:34 +01:00
parent 451e337979
commit c1992535de

View File

@ -32,6 +32,7 @@
#endif
#include <sqlpp11/functions.h>
#include <sqlpp11/insert.h>
#include <sqlpp11/select.h>
int Insert(int, char*[])
{
@ -39,7 +40,7 @@ int Insert(int, char*[])
MockDb::_serializer_context_t printer = {};
const auto t = test::TabBar{};
const auto tabDateTime = test::TabDateTime{};
// test::TabFoo f;
const auto u = test::TabFoo{};
{
using T = decltype(insert_into(t));
@ -98,6 +99,8 @@ int Insert(int, char*[])
db(insert_into(t).set(t.gamma = true, t.delta = 0));
db(insert_into(t).set(values()));
db(insert_into(t).set(t.gamma = true, t.delta = 0, t.beta = select(u.delta).from(u).unconditionally()));
auto prepared_insert = db.prepare(insert_into(t).set(t.gamma = parameter(t.gamma), t.delta = parameter(t.delta)));
prepared_insert.params.gamma = true;
prepared_insert.params.delta = sqlpp::null;