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

Function TestQuery_NestedComposition

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

Source from the content-addressed store, hash-verified

245}
246
247func TestQuery_NestedComposition(t *testing.T) {
248 // Build a subquery
249 subquery := Q().Space("SELECT user_id FROM orders WHERE total > ?", 100)
250
251 // Use it in main query
252 q := Q().Space("SELECT * FROM users").
253 Where("id IN (?)", subquery)
254
255 sql, args, err := q.ToSQL()
256 require.NoError(t, err)
257 require.Equal(t, "SELECT * FROM users WHERE id IN (SELECT user_id FROM orders WHERE total > $1)", sql)
258 require.Equal(t, []any{100}, args)
259}
260
261func TestQuery_PracticalComposition(t *testing.T) {
262 // Realistic example: build a complex query with reusable parts

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected