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

Function TestQuery_CommaWithNullHandling

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

Source from the content-addressed store, hash-verified

426}
427
428func TestQuery_CommaWithNullHandling(t *testing.T) {
429 // UPDATE with NULL assignment
430 projectID := "proj-1"
431 environmentID := "" // Empty string means NULL
432
433 set := Q()
434 set.Comma("project = ?", projectID)
435 if environmentID == "" {
436 set.Comma("environment = NULL")
437 } else {
438 set.Comma("environment = ?", environmentID)
439 }
440
441 q := Q().Space("UPDATE db SET ?", set).
442 Space("WHERE instance = ? AND name = ?", "inst-1", "db-1")
443
444 sql, args, err := q.ToSQL()
445 require.NoError(t, err)
446 require.Equal(t, "UPDATE db SET project = $1, environment = NULL WHERE instance = $2 AND name = $3", sql)
447 require.Equal(t, []any{"proj-1", "inst-1", "db-1"}, args)
448}
449
450func TestQuery_Len(t *testing.T) {
451 // Test Len() method

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