Skip to content

Commit

Permalink
#36: Add UnionAll + FullOuterJoin
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Dec 15, 2019
1 parent f4fc7bf commit 2057d8e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 2057d8e

Please sign in to comment.