MCPcopy Create free account
hub / github.com/go-pg/pg / TestQueryFormatQuery

Function TestQueryFormatQuery

orm/query_test.go:10–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestQueryFormatQuery(t *testing.T) {
11 type FormatModel struct {
12 Foo string
13 Bar string
14 }
15
16 q := NewQuery(nil, &FormatModel{"foo", "bar"})
17
18 params := &struct {
19 Foo string
20 }{
21 "not_foo",
22 }
23 fmter := NewFormatter().WithModel(q)
24 b := fmter.FormatQuery(nil, "?foo ?TableName ?TableAlias ?TableColumns ?Columns", params)
25
26 wanted := `'not_foo' "format_models" "format_model" "format_model"."foo", "format_model"."bar" "foo", "bar"`
27 if string(b) != wanted {
28 t.Fatalf("got `%s`, wanted `%s`", string(b), wanted)
29 }
30}
31
32var _ = Describe("NewQuery", func() {
33 It("works with nil db", func() {

Callers

nothing calls this directly

Calls 4

NewQueryFunction · 0.85
NewFormatterFunction · 0.85
WithModelMethod · 0.80
FormatQueryMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…