MCPcopy
hub / github.com/Masterminds/squirrel / TestDeleteBuilderToSql

Function TestDeleteBuilderToSql

delete_test.go:9–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestDeleteBuilderToSql(t *testing.T) {
10 b := Delete("").
11 Prefix("WITH prefix AS ?", 0).
12 From("a").
13 Where("b = ?", 1).
14 OrderBy("c").
15 Limit(2).
16 Offset(3).
17 Suffix("RETURNING ?", 4)
18
19 sql, args, err := b.ToSql()
20 assert.NoError(t, err)
21
22 expectedSql :=
23 "WITH prefix AS ? " +
24 "DELETE FROM a WHERE b = ? ORDER BY c LIMIT 2 OFFSET 3 " +
25 "RETURNING ?"
26 assert.Equal(t, expectedSql, sql)
27
28 expectedArgs := []interface{}{0, 1, 4}
29 assert.Equal(t, expectedArgs, args)
30}
31
32func TestDeleteBuilderToSqlErr(t *testing.T) {
33 _, _, err := Delete("").ToSql()

Callers

nothing calls this directly

Calls 9

DeleteFunction · 0.85
ToSqlMethod · 0.65
SuffixMethod · 0.45
OffsetMethod · 0.45
LimitMethod · 0.45
OrderByMethod · 0.45
WhereMethod · 0.45
FromMethod · 0.45
PrefixMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…