MCPcopy Create free account
hub / github.com/Masterminds/squirrel / TestCaseWithComplexVal

Function TestCaseWithComplexVal

case_test.go:34–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32}
33
34func TestCaseWithComplexVal(t *testing.T) {
35 caseStmt := Case("? > ?", 10, 5).
36 When("true", "'T'")
37
38 qb := Select().
39 Column(Alias(caseStmt, "complexCase")).
40 From("table")
41 sql, args, err := qb.ToSql()
42
43 assert.NoError(t, err)
44
45 expectedSql := "SELECT (CASE ? > ? " +
46 "WHEN true THEN 'T' " +
47 "END) AS complexCase " +
48 "FROM table"
49 assert.Equal(t, expectedSql, sql)
50
51 expectedArgs := []interface{}{10, 5}
52 assert.Equal(t, expectedArgs, args)
53}
54
55func TestCaseWithNoVal(t *testing.T) {
56 caseStmt := Case().

Callers

nothing calls this directly

Calls 7

CaseFunction · 0.85
SelectFunction · 0.85
AliasFunction · 0.85
WhenMethod · 0.80
ColumnMethod · 0.80
ToSqlMethod · 0.65
FromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…