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

Function TestSelectSubqueryPlaceholderNumbering

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

Source from the content-addressed store, hash-verified

248}
249
250func TestSelectSubqueryPlaceholderNumbering(t *testing.T) {
251 subquery := Select("a").Where("b = ?", 1).PlaceholderFormat(Dollar)
252 with := subquery.Prefix("WITH a AS (").Suffix(")")
253
254 sql, args, err := Select("*").
255 PrefixExpr(with).
256 FromSelect(subquery, "q").
257 Where("c = ?", 2).
258 PlaceholderFormat(Dollar).
259 ToSql()
260 assert.NoError(t, err)
261
262 expectedSql := "WITH a AS ( SELECT a WHERE b = $1 ) SELECT * FROM (SELECT a WHERE b = $2) AS q WHERE c = $3"
263 assert.Equal(t, expectedSql, sql)
264 assert.Equal(t, []interface{}{1, 1, 2}, args)
265}
266
267func TestSelectSubqueryInConjunctionPlaceholderNumbering(t *testing.T) {
268 subquery := Select("a").Where(Eq{"b": 1}).Prefix("EXISTS(").Suffix(")").PlaceholderFormat(Dollar)

Callers

nothing calls this directly

Calls 8

SelectFunction · 0.85
ToSqlMethod · 0.65
PlaceholderFormatMethod · 0.45
WhereMethod · 0.45
SuffixMethod · 0.45
PrefixMethod · 0.45
FromSelectMethod · 0.45
PrefixExprMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…