Global AND and OR functions for better indentation of a complex condition in the Go code and in the generated SQL.

This commit is contained in:
go-jet 2022-02-11 13:09:49 +01:00
parent 8ffbe38993
commit 9f91fd705a
17 changed files with 338 additions and 44 deletions

View file

@ -2,6 +2,15 @@ package mysql
import "github.com/go-jet/jet/v2/internal/jet"
// This functions can be used, instead of its method counterparts, to have a better indentation of a complex condition
// in the Go code and in the generated SQL.
var (
// AND function adds AND operator between expressions.
AND = jet.AND
// OR function adds OR operator between expressions.
OR = jet.OR
)
// ROW is construct one table row from list of expressions.
var ROW = jet.ROW

View file

@ -148,9 +148,9 @@ func TestSelect_NOT_EXISTS(t *testing.T) {
SELECT table1.col_int AS "table1.col_int"
FROM db.table1
WHERE NOT (EXISTS (
SELECT table2.col_int AS "table2.col_int"
FROM db.table2
WHERE table1.col_int = table2.col_int
));
SELECT table2.col_int AS "table2.col_int"
FROM db.table2
WHERE table1.col_int = table2.col_int
));
`)
}