-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_test.go
52 lines (45 loc) · 1.24 KB
/
access_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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package pgtalk
import (
"testing"
"github.com/emicklei/pgtalk/convert"
"github.com/jackc/pgx/v5/pgtype"
)
func TestLiteral_String(t *testing.T) {
l := newLiteralString("literal")
ls := testSQL(l)
if got, want := ls, "'literal'"; got != want {
t.Errorf("got [%v:%T] want [%v:%T]", got, got, want, want)
}
}
func TestStringWithNonNilFields_poly(t *testing.T) {
p := poly{}
f := 42.0
p.FFloat = f
if got, want := StringWithFields(p, false), "github.com/emicklei/pgtalk.poly{FFloat:42 }"; got != want {
t.Errorf("got [%v:%T] want [%v:%T]", got, got, want, want)
}
}
func TestStringWithNonNilFields_pointerpoly(t *testing.T) {
p := new(poly)
f := 42.0
p.FFloat = f
if got, want := StringWithFields(p, false), "github.com/emicklei/pgtalk.poly{FFloat:42 }"; got != want {
t.Errorf("got [%v:%T] want [%v:%T]", got, got, want, want)
}
}
func TestGetStringOfPoly(t *testing.T) {
th := new(poly)
th.expressionResults = map[string]any{
"k": 42,
}
t.Log(StringWithFields(th, HideNilValues))
}
func TestUUID_IN_SQL(t *testing.T) {
a := NewFieldAccess[pgtype.UUID](ColumnInfo{ti, "col", false, false, false}, nil)
ids := []pgtype.UUID{
convert.StringToUUID("b344a1918d0cbd1542de669644dd1bfd"),
}
ex := a.In(ids...)
sql := SQL(ex)
t.Log(sql)
}