MCPcopy
hub / github.com/github/gh-ost / TestBuildTwoColumnUnionParts

Function TestBuildTwoColumnUnionParts

go/sql/builder_test.go:644–659  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

642}
643
644func TestBuildTwoColumnUnionParts(t *testing.T) {
645 rangeStartArgs := []interface{}{3, 17}
646 rangeEndArgs := []interface{}{103, 117}
647 part1, part2, part3, explodedArgs := buildTwoColumnUnionParts(
648 "name, position", "mydb.tbl",
649 "name", "position",
650 "?", "?", "?", "?",
651 ">=", "order by name asc, position asc limit 500",
652 rangeStartArgs, rangeEndArgs,
653 )
654 require.Equal(t, normalizeQuery("(select name, position from mydb.tbl where name = ? and position >= ? order by name asc, position asc limit 500)"), normalizeQuery(part1))
655 require.Equal(t, normalizeQuery("(select name, position from mydb.tbl where name > ? and name < ? order by name asc, position asc limit 500)"), normalizeQuery(part2))
656 require.Equal(t, normalizeQuery("(select name, position from mydb.tbl where name = ? and position <= ? order by name asc, position asc limit 500)"), normalizeQuery(part3))
657 // Args follow the column order each subquery binds: (start1, start2), (start1, end1), (end1, end2).
658 require.Equal(t, []interface{}{3, 17, 3, 103, 103, 117}, explodedArgs)
659}
660
661func TestBuildRangeInsertQueryTwoColumnGuards(t *testing.T) {
662 databaseName := "mydb"

Callers

nothing calls this directly

Calls 2

buildTwoColumnUnionPartsFunction · 0.85
normalizeQueryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…