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

Function TestSelectBuilderFromSelectNestedDollarPlaceholders

select_test.go:75–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestSelectBuilderFromSelectNestedDollarPlaceholders(t *testing.T) {
76 subQ := Select("c").
77 From("t").
78 Where(Gt{"c": 1}).
79 PlaceholderFormat(Dollar)
80 b := Select("c").
81 FromSelect(subQ, "subq").
82 Where(Lt{"c": 2}).
83 PlaceholderFormat(Dollar)
84 sql, args, err := b.ToSql()
85 assert.NoError(t, err)
86
87 expectedSql := "SELECT c FROM (SELECT c FROM t WHERE c > $1) AS subq WHERE c < $2"
88 assert.Equal(t, expectedSql, sql)
89
90 expectedArgs := []interface{}{1, 2}
91 assert.Equal(t, expectedArgs, args)
92}
93
94func TestSelectBuilderToSqlErr(t *testing.T) {
95 _, _, err := Select().From("x").ToSql()

Callers

nothing calls this directly

Calls 6

SelectFunction · 0.85
ToSqlMethod · 0.65
PlaceholderFormatMethod · 0.45
WhereMethod · 0.45
FromMethod · 0.45
FromSelectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…