From 2057d8eace1ddf0aebb66fac674f67bb2aeac2f8 Mon Sep 17 00:00:00 2001 From: akushman Date: Sun, 15 Dec 2019 19:15:41 +0100 Subject: [PATCH] #36: Add UnionAll + FullOuterJoin --- builder_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/builder_test.go b/builder_test.go index a8f7ab6..65318bf 100644 --- a/builder_test.go +++ b/builder_test.go @@ -731,3 +731,25 @@ func TestDB_LockForUpdate(t *testing.T) { assert.Equal(t, len(res), len(batchUsers)) db.Truncate(UsersTable) } + +func TestDB_UnionAll(t *testing.T) { + db.Truncate(UsersTable) + err := db.Table(UsersTable).InsertBatch(batchUsers) + assert.NoError(t, err) + + res, err := db.Table(UsersTable).Select("name").UnionAll().Table(UsersTable).Get() + assert.NoError(t, err) + assert.Equal(t, len(res), len(batchUsers)) + db.Truncate(UsersTable) +} + +func TestDB_FullOuterJoin(t *testing.T) { + db.Truncate(UsersTable) + err := db.Table(UsersTable).InsertBatch(batchUsers) + assert.NoError(t, err) + + res, err := db.Table(UsersTable).Select("name").FullOuterJoin(PostsTable, "users.id", "=", "posts.user_id").Get() + assert.NoError(t, err) + assert.Equal(t, len(res), len(batchUsers)) + db.Truncate(UsersTable) +}