-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcond_exists_test.go
More file actions
32 lines (26 loc) · 948 Bytes
/
cond_exists_test.go
File metadata and controls
32 lines (26 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2022 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package builder
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestExists(t *testing.T) {
cond1 := Exists(Select("*").From("table").Where(Eq{"col1": 1}))
sql, err := ToBoundSQL(cond1)
assert.NoError(t, err)
assert.EqualValues(t, "EXISTS (SELECT * FROM table WHERE col1=1)", sql)
}
func TestNotExists1(t *testing.T) {
cond1 := Exists(Select("*").From("table").Where(Eq{"col1": 1}))
sql, err := ToBoundSQL(Not{cond1})
assert.NoError(t, err)
assert.EqualValues(t, "NOT EXISTS (SELECT * FROM table WHERE col1=1)", sql)
}
func TestNotExists2(t *testing.T) {
cond1 := NotExists(Select("*").From("table").Where(Eq{"col1": 1}))
sql, err := ToBoundSQL(cond1)
assert.NoError(t, err)
assert.EqualValues(t, "NOT EXISTS (SELECT * FROM table WHERE col1=1)", sql)
}