MCPcopy
hub / github.com/upper/db / TestDelete

Function TestDelete

internal/sqlbuilder/builder_test.go:1460–1480  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1458}
1459
1460func TestDelete(t *testing.T) {
1461 bt := WithTemplate(&testTemplate)
1462 assert := assert.New(t)
1463
1464 assert.Equal(
1465 `DELETE FROM "artist" WHERE (name = $1)`,
1466 bt.DeleteFrom("artist").Where("name = ?", "Chavela Vargas").String(),
1467 )
1468
1469 assert.Equal(
1470 `DELETE FROM "artist" WHERE (name = $1) RETURNING 1`,
1471 bt.DeleteFrom("artist").Where("name = ?", "Chavela Vargas").Amend(func(query string) string {
1472 return fmt.Sprintf("%s RETURNING 1", query)
1473 }).String(),
1474 )
1475
1476 assert.Equal(
1477 `DELETE FROM "artist" WHERE (id > 5)`,
1478 bt.DeleteFrom("artist").Where("id > 5").String(),
1479 )
1480}
1481
1482func TestPaginate(t *testing.T) {
1483 b := &sqlBuilder{t: newTemplateWithUtils(&testTemplate)}

Callers

nothing calls this directly

Calls 6

WithTemplateFunction · 0.85
NewMethod · 0.65
StringMethod · 0.65
WhereMethod · 0.65
DeleteFromMethod · 0.65
AmendMethod · 0.65

Tested by

no test coverage detected