forked from slicebit/qb
-
Notifications
You must be signed in to change notification settings - Fork 2
/
where_test.go
37 lines (32 loc) · 875 Bytes
/
where_test.go
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
33
34
35
36
37
package qb
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWhere(t *testing.T) {
ctx := NewCompilerContext(NewDefaultDialect())
assert.Equal(t,
"WHERE X",
Where(SQLText("X")).Accept(ctx))
assert.Equal(t,
"WHERE (X AND Y)",
Where(SQLText("X"), SQLText("Y")).Accept(ctx))
}
func TestWhereAnd(t *testing.T) {
ctx := NewCompilerContext(NewDefaultDialect())
assert.Equal(t,
"WHERE (X AND Y)",
Where(SQLText("X")).And(SQLText("Y")).Accept(ctx))
assert.Equal(t,
"WHERE (X AND Y AND Z)",
Where(SQLText("X")).And(SQLText("Y"), SQLText("Z")).Accept(ctx))
}
func TestWhereOr(t *testing.T) {
ctx := NewCompilerContext(NewDefaultDialect())
assert.Equal(t,
"WHERE (X OR Y)",
Where(SQLText("X")).Or(SQLText("Y")).Accept(ctx))
assert.Equal(t,
"WHERE (X OR Y OR Z)",
Where(SQLText("X")).Or(SQLText("Y"), SQLText("Z")).Accept(ctx))
}