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:
parent
451e337979
commit
c1992535de
@ -32,6 +32,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <sqlpp11/functions.h>
|
#include <sqlpp11/functions.h>
|
||||||
#include <sqlpp11/insert.h>
|
#include <sqlpp11/insert.h>
|
||||||
|
#include <sqlpp11/select.h>
|
||||||
|
|
||||||
int Insert(int, char*[])
|
int Insert(int, char*[])
|
||||||
{
|
{
|
||||||
@ -39,7 +40,7 @@ int Insert(int, char*[])
|
|||||||
MockDb::_serializer_context_t printer = {};
|
MockDb::_serializer_context_t printer = {};
|
||||||
const auto t = test::TabBar{};
|
const auto t = test::TabBar{};
|
||||||
const auto tabDateTime = test::TabDateTime{};
|
const auto tabDateTime = test::TabDateTime{};
|
||||||
// test::TabFoo f;
|
const auto u = test::TabFoo{};
|
||||||
|
|
||||||
{
|
{
|
||||||
using T = decltype(insert_into(t));
|
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(t.gamma = true, t.delta = 0));
|
||||||
db(insert_into(t).set(values()));
|
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)));
|
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.gamma = true;
|
||||||
prepared_insert.params.delta = sqlpp::null;
|
prepared_insert.params.delta = sqlpp::null;
|
||||||
|
Loading…
Reference in New Issue
Block a user