Skip to content

Commit c606211

Browse files
committed
Added a few more UNION tests
1 parent ae37d06 commit c606211

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/Union.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
#include <sqlpp11/alias_provider.h>
3030
#include <iostream>
3131

32+
namespace greek
33+
{
34+
SQLPP_ALIAS_PROVIDER(alpha)
35+
SQLPP_ALIAS_PROVIDER(beta)
36+
}
37+
3238
int Union(int, char* [])
3339
{
3440
MockDb db;
@@ -40,6 +46,15 @@ int Union(int, char* [])
4046
db(select(t.alpha).from(t).unconditionally().union_distinct(select(f.epsilon.as(t.alpha)).from(f).unconditionally()));
4147
db(select(t.alpha).from(t).unconditionally().union_all(select(f.epsilon.as(t.alpha)).from(f).unconditionally()));
4248

49+
// t.alpha can be null, a given value cannot
50+
db(select(t.alpha).from(t).unconditionally().union_all(select(sqlpp::value(1).as(t.alpha))));
51+
db(select(t.alpha).from(t).unconditionally().union_all(select(sqlpp::value(1).as(greek::alpha))));
52+
53+
// t.beta can be null, f.delta cannot
54+
static_assert(sqlpp::can_be_null_t<decltype(t.beta)>::value, "");
55+
static_assert(!sqlpp::can_be_null_t<decltype(f.delta)>::value, "");
56+
db(select(t.beta).from(t).unconditionally().union_all(select(f.delta.as(greek::beta)).from(f).unconditionally()));
57+
4358
auto u = select(t.alpha)
4459
.from(t)
4560
.unconditionally()

0 commit comments

Comments
 (0)