@@ -56,7 +56,7 @@ func TestWhere(t *testing.T) {
5656 }, clause.Where {
5757 Exprs : []clause.Expression {clause .Or (clause .Not (clause.Gt {Column : "score" , Value : 100 }), clause.Like {Column : "name" , Value : "%linus%" })},
5858 }},
59- "SELECT * FROM `users` WHERE (`users`.`id` <> ? AND `age` <= ?) OR `name` <> ? AND (`score` <= ? OR `name` LIKE ?)" ,
59+ "SELECT * FROM `users` WHERE (`users`.`id` <> ? OR `age` <= ?) OR `name` <> ? AND (`score` <= ? OR `name` LIKE ?)" ,
6060 []interface {}{"1" , 18 , "jinzhu" , 100 , "%linus%" },
6161 },
6262 {
@@ -70,21 +70,21 @@ func TestWhere(t *testing.T) {
7070 []clause.Interface {clause.Select {}, clause.From {}, clause.Where {
7171 Exprs : []clause.Expression {clause .Not (clause.Eq {Column : clause .PrimaryColumn , Value : "1" }, clause.Gt {Column : "age" , Value : 18 }), clause .And (clause.Expr {SQL : "`score` <= ?" , Vars : []interface {}{100 }, WithoutParentheses : false })},
7272 }},
73- "SELECT * FROM `users` WHERE (`users`.`id` <> ? AND `age` <= ?) AND `score` <= ?" ,
73+ "SELECT * FROM `users` WHERE (`users`.`id` <> ? OR `age` <= ?) AND `score` <= ?" ,
7474 []interface {}{"1" , 18 , 100 },
7575 },
7676 {
7777 []clause.Interface {clause.Select {}, clause.From {}, clause.Where {
7878 Exprs : []clause.Expression {clause .Not (clause.Eq {Column : clause .PrimaryColumn , Value : "1" }, clause.Gt {Column : "age" , Value : 18 }), clause.Expr {SQL : "`score` <= ?" , Vars : []interface {}{100 }, WithoutParentheses : false }},
7979 }},
80- "SELECT * FROM `users` WHERE (`users`.`id` <> ? AND `age` <= ?) AND `score` <= ?" ,
80+ "SELECT * FROM `users` WHERE (`users`.`id` <> ? OR `age` <= ?) AND `score` <= ?" ,
8181 []interface {}{"1" , 18 , 100 },
8282 },
8383 {
8484 []clause.Interface {clause.Select {}, clause.From {}, clause.Where {
8585 Exprs : []clause.Expression {clause .Not (clause.Eq {Column : clause .PrimaryColumn , Value : "1" }, clause.Gt {Column : "age" , Value : 18 }), clause .Or (clause.Expr {SQL : "`score` <= ?" , Vars : []interface {}{100 }, WithoutParentheses : false })},
8686 }},
87- "SELECT * FROM `users` WHERE (`users`.`id` <> ? AND `age` <= ?) OR `score` <= ?" ,
87+ "SELECT * FROM `users` WHERE (`users`.`id` <> ? OR `age` <= ?) OR `score` <= ?" ,
8888 []interface {}{"1" , 18 , 100 },
8989 },
9090 {
@@ -102,7 +102,7 @@ func TestWhere(t *testing.T) {
102102 Exprs : []clause.Expression {clause .Not (clause.Eq {Column : clause .PrimaryColumn , Value : "1" },
103103 clause .And (clause.Expr {SQL : "`score` <= ?" , Vars : []interface {}{100 }, WithoutParentheses : false }))},
104104 }},
105- "SELECT * FROM `users` WHERE (`users`.`id` <> ? AND NOT `score` <= ?)" ,
105+ "SELECT * FROM `users` WHERE (`users`.`id` <> ? OR NOT `score` <= ?)" ,
106106 []interface {}{"1" , 100 },
107107 },
108108 {
@@ -116,16 +116,21 @@ func TestWhere(t *testing.T) {
116116 {
117117 []clause.Interface {clause.Select {}, clause.From {}, clause.Where {
118118 Exprs : []clause.Expression {
119- clause .Not (clause.AndConditions {
120- Exprs : []clause.Expression {
121- clause.Eq {Column : clause .PrimaryColumn , Value : "1" },
122- clause.Gt {Column : "age" , Value : 18 },
123- }}, clause.OrConditions {
124- Exprs : []clause.Expression {
125- clause.Lt {Column : "score" , Value : 100 },
119+ clause .Not (
120+ clause.AndConditions {
121+ Exprs : []clause.Expression {
122+ clause.Eq {Column : clause .PrimaryColumn , Value : "1" },
123+ clause.Gt {Column : "age" , Value : 18 },
124+ },
126125 },
127- }),
128- }}},
126+ clause.OrConditions {
127+ Exprs : []clause.Expression {
128+ clause.Lt {Column : "score" , Value : 100 },
129+ },
130+ },
131+ ),
132+ },
133+ }},
129134 "SELECT * FROM `users` WHERE NOT ((`users`.`id` = ? AND `age` > ?) OR `score` < ?)" ,
130135 []interface {}{"1" , 18 , 100 },
131136 },
0 commit comments