You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// CTE represents a single common table expression. They are composed of an alias, a few optional components, and a data manipulation statement, though exactly what sort of statement depends on the database system you're using. MySQL, for example, only allows SELECT statements; others, like PostgreSQL, permit INSERTs, UPDATEs, and DELETEs.
9
+
// The optional components supported by this fork of Squirrel include:
10
+
// * a list of columns
11
+
// * the keyword RECURSIVE, the use of which may place additional constraints on the data manipulation statement
expectedSql=`SELECT column1, column2 FROM table1 WHERE column1 = $1 `+
509
+
"UNION SELECT column3, column4 FROM table2 WHERE column4 < $2 "+
510
+
"UNION SELECT column5, column6 FROM table3 WHERE column5 <= $3"
511
+
assert.Equal(t, expectedSql, sql)
512
+
513
+
unionAll:=Select("count(true) as C").
514
+
From("table1").
515
+
Where(Eq{"column1": []string{"test", "tester"}}).
516
+
UnionAllSelect(Select("count(true) as C").From("table2").Where(Select("true").Prefix("NOT EXISTS(").Suffix(")").From("table3").Where("id=table2.column3")))
517
+
sql, args, err=unionAll.ToSql()
518
+
assert.NoError(t, err)
519
+
520
+
expectedSql=`SELECT count(true) as C FROM table1 WHERE column1 IN (?,?) `+
521
+
"UNION ALL SELECT count(true) as C FROM table2 WHERE NOT EXISTS( SELECT true FROM table3 WHERE id=table2.column3 )"
0 commit comments