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

Function TestSelectBuilderNestedSelectJoin

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

Source from the content-addressed store, hash-verified

173}
174
175func TestSelectBuilderNestedSelectJoin(t *testing.T) {
176
177 expectedSql := "SELECT * FROM bar JOIN ( SELECT * FROM baz WHERE foo = ? ) r ON bar.foo = r.foo"
178 expectedArgs := []interface{}{42}
179
180 nestedSelect := Select("*").From("baz").Where("foo = ?", 42)
181
182 b := Select("*").From("bar").JoinClause(nestedSelect.Prefix("JOIN (").Suffix(") r ON bar.foo = r.foo"))
183
184 sql, args, err := b.ToSql()
185 assert.NoError(t, err)
186
187 assert.Equal(t, expectedSql, sql)
188 assert.Equal(t, args, expectedArgs)
189}
190
191func TestSelectWithOptions(t *testing.T) {
192 sql, _, err := Select("*").From("foo").Distinct().Options("SQL_NO_CACHE").ToSql()

Callers

nothing calls this directly

Calls 7

SelectFunction · 0.85
JoinClauseMethod · 0.80
ToSqlMethod · 0.65
WhereMethod · 0.45
FromMethod · 0.45
SuffixMethod · 0.45
PrefixMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…