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

Function TestQuery_CommaInUpdate

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

Source from the content-addressed store, hash-verified

406}
407
408func TestQuery_CommaInUpdate(t *testing.T) {
409 // Realistic UPDATE with conditional SET fields
410 name := "Alice"
411 active := true
412
413 set := Q()
414 if name != "" {
415 set.Comma("name = ?", name)
416 }
417 set.Comma("active = ?", active)
418
419 q := Q().Space("UPDATE users SET ?", set).
420 Space("WHERE id = ?", 123)
421
422 sql, args, err := q.ToSQL()
423 require.NoError(t, err)
424 require.Equal(t, "UPDATE users SET name = $1, active = $2 WHERE id = $3", sql)
425 require.Equal(t, []any{"Alice", true, 123}, args)
426}
427
428func TestQuery_CommaWithNullHandling(t *testing.T) {
429 // UPDATE with NULL assignment

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected