test(qb): Add tests for qb section (#74)
test(qb): Add missing tests for qb directory * Add a GROUP BY test without Columns * Add LtFunc test * Add LtOrEqFunc test * Add GtFunc test * Add GtOrEqFunc test * Add a Select with a AS between one column test * Add a Order By DESC test * Add Sum test * Add Avg test * Add Max test * Add 2 tests for FuncColumn * Add SetNamed test * Add AddFunc test * Add RemoveFunc test * Add TTL and TimestampNamed test * Add TTLNamed and Timestamp test * Add TTL with negative or no duration test * Add LtFunc test * Add LtOrEqFunc test * Add GtFunc test * Add GtOrEqFunc test * Add a Select with a AS between one column test * Add a Order By DESC test * Add Sum test * Add Avg test * Add Max test * Add SetNamed test * Add AddFunc test * Add RemoveFunc test * Add TTL and TimestampNamed test * Add TTLNamed and Timestamp test * Add TTL with negative or no duration test * Add LtFunc test * Add LtOrEqFunc test * Add GtFunc test * Add GtOrEqFunc test * Add a Select with a AS between one column test * Add a Order By DESC test * Add Sum test * Add Avg test * Add Max test * Add 2 tests for FuncColumn * Add SetNamed test * Add AddFunc test * Add RemoveFunc test * In qb/select.go, if there are no colums and the query have a GroupBy statement then the query will be malformated. * In qb/utils.go, refactor writeCql with a strings.Join call. Fixes #78
This commit is contained in:
committed by
Michal Matczuk
parent
dcec9d031f
commit
87976451ed
@@ -33,6 +33,12 @@ func TestSelectBuilder(t *testing.T) {
|
||||
B: Select("cycling.cyclist_name").Columns("id", "user_uuid", As("firstname", "name")),
|
||||
S: "SELECT id,user_uuid,firstname AS name FROM cycling.cyclist_name ",
|
||||
},
|
||||
// Add a SELECT AS column 2
|
||||
{
|
||||
B: Select("cycling.cyclist_name").
|
||||
Columns(As("firstname", "name"), "id", As("user_uuid", "user")),
|
||||
S: "SELECT firstname AS name,id,user_uuid AS user FROM cycling.cyclist_name ",
|
||||
},
|
||||
// Basic test for select distinct
|
||||
{
|
||||
B: Select("cycling.cyclist_name").Distinct("id"),
|
||||
@@ -70,6 +76,12 @@ func TestSelectBuilder(t *testing.T) {
|
||||
S: "SELECT * FROM cycling.cyclist_name WHERE id=? ORDER BY firstname ASC ",
|
||||
N: []string{"expr"},
|
||||
},
|
||||
// Add ORDER BY
|
||||
{
|
||||
B: Select("cycling.cyclist_name").Where(w).OrderBy("firstname", DESC),
|
||||
S: "SELECT * FROM cycling.cyclist_name WHERE id=? ORDER BY firstname DESC ",
|
||||
N: []string{"expr"},
|
||||
},
|
||||
// Add ORDER BY two columns
|
||||
{
|
||||
B: Select("cycling.cyclist_name").Where(w).OrderBy("firstname", ASC).OrderBy("lastname", DESC),
|
||||
@@ -110,6 +122,21 @@ func TestSelectBuilder(t *testing.T) {
|
||||
B: Select("cycling.cyclist_name").Min("stars"),
|
||||
S: "SELECT min(stars) FROM cycling.cyclist_name ",
|
||||
},
|
||||
// Add Sum
|
||||
{
|
||||
B: Select("cycling.cyclist_name").Sum("*") ,
|
||||
S: "SELECT sum(*) FROM cycling.cyclist_name ",
|
||||
},
|
||||
// Add Avg
|
||||
{
|
||||
B: Select("cycling.cyclist_name").Avg("stars"),
|
||||
S: "SELECT avg(stars) FROM cycling.cyclist_name ",
|
||||
},
|
||||
// Add Max
|
||||
{
|
||||
B: Select("cycling.cyclist_name").Max("stars"),
|
||||
S: "SELECT max(stars) FROM cycling.cyclist_name ",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range table {
|
||||
|
||||
Reference in New Issue
Block a user