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

Function TestUpdateBuilderFromSelect

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

Source from the content-addressed store, hash-verified

90}
91
92func TestUpdateBuilderFromSelect(t *testing.T) {
93 sql, _, err := Update("employees").
94 Set("sales_count", 100).
95 FromSelect(Select("id").
96 From("accounts").
97 Where("accounts.name = ?", "ACME"), "subquery").
98 Where("employees.account_id = subquery.id").ToSql()
99 assert.NoError(t, err)
100
101 expectedSql :=
102 "UPDATE employees " +
103 "SET sales_count = ? " +
104 "FROM (SELECT id FROM accounts WHERE accounts.name = ?) AS subquery " +
105 "WHERE employees.account_id = subquery.id"
106 assert.Equal(t, expectedSql, sql)
107}

Callers

nothing calls this directly

Calls 7

UpdateFunction · 0.85
SelectFunction · 0.85
SetMethod · 0.80
ToSqlMethod · 0.65
WhereMethod · 0.45
FromSelectMethod · 0.45
FromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…