MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestQuery_MultipleParameters

Function TestQuery_MultipleParameters

backend/common/qb/qb_test.go:25–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func TestQuery_MultipleParameters(t *testing.T) {
26 q := Q().Space("SELECT * FROM users").
27 Where("id = ?", 123).
28 And("active = ?", true).
29 And("role = ?", "admin")
30 sql, args, err := q.ToSQL()
31 require.NoError(t, err)
32 require.Equal(t, "SELECT * FROM users WHERE id = $1 AND active = $2 AND role = $3", sql)
33 require.Equal(t, []any{123, true, "admin"}, args)
34}
35
36func TestQuery_AndOr(t *testing.T) {
37 q := Q().Space("SELECT * FROM users").

Callers

nothing calls this directly

Calls 6

QFunction · 0.85
AndMethod · 0.80
WhereMethod · 0.80
SpaceMethod · 0.80
ToSQLMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected