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

Function TestQuery_ComplexConditions

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

Source from the content-addressed store, hash-verified

77}
78
79func TestQuery_ComplexConditions(t *testing.T) {
80 q := Q().Space("SELECT * FROM revision").
81 Where("TRUE").
82 And("instance = ?", "prod").
83 And("db_name = ?", "main").
84 And("payload->>'type' = ?", "MIGRATE").
85 And("deleted_at IS NULL").
86 Space("ORDER BY version DESC").
87 Space("LIMIT ?", 10).
88 Space("OFFSET ?", 20)
89 sql, args, err := q.ToSQL()
90 require.NoError(t, err)
91 require.Equal(t, "SELECT * FROM revision WHERE TRUE AND instance = $1 AND db_name = $2 AND payload->>'type' = $3 AND deleted_at IS NULL ORDER BY version DESC LIMIT $4 OFFSET $5", sql)
92 require.Equal(t, []any{"prod", "main", "MIGRATE", 10, 20}, args)
93}
94
95func TestQuery_ArrayParameter(t *testing.T) {
96 versions := []string{"v1", "v2", "v3"}

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected