(t *testing.T)
| 248 | } |
| 249 | |
| 250 | func 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 | |
| 267 | func TestSelectSubqueryInConjunctionPlaceholderNumbering(t *testing.T) { |
| 268 | subquery := Select("a").Where(Eq{"b": 1}).Prefix("EXISTS(").Suffix(")").PlaceholderFormat(Dollar) |
nothing calls this directly
no test coverage detected
searching dependent graphs…