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

Function TestQuery_JSONBWithComposition

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

Source from the content-addressed store, hash-verified

377}
378
379func TestQuery_JSONBWithComposition(t *testing.T) {
380 // Test JSONB operators with query composition
381 labelFilter := Q().Space("payload->'labels' ??& ?::TEXT[]", []string{"important"})
382 typeFilter := Q().Space("payload ?? 'type'")
383
384 q := Q().Space("SELECT * FROM issues").
385 Where("?", labelFilter).
386 And("?", typeFilter).
387 And("status = ?", "open")
388
389 sql, args, err := q.ToSQL()
390 require.NoError(t, err)
391 require.Equal(t, "SELECT * FROM issues WHERE payload->'labels' ?& $1::TEXT[] AND payload ? 'type' AND status = $2", sql)
392 require.Equal(t, []any{[]string{"important"}, "open"}, args)
393}
394
395func TestQuery_Comma(t *testing.T) {
396 // Build a SET clause with comma separators

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