@@ -25,11 +25,9 @@ func NewCond() *Cond {
25
25
26
26
// Equal is used to construct the expression "field = value".
27
27
func (c * Cond ) Equal (field string , value interface {}) string {
28
- escaped := Escape (field )
29
-
30
28
return c .Var (condBuilder {
31
29
Builder : func (ctx * argsCompileContext ) {
32
- ctx .WriteString (escaped )
30
+ ctx .WriteString (field )
33
31
ctx .WriteString (" = " )
34
32
ctx .WriteValue (value )
35
33
},
@@ -48,11 +46,9 @@ func (c *Cond) EQ(field string, value interface{}) string {
48
46
49
47
// NotEqual is used to construct the expression "field <> value".
50
48
func (c * Cond ) NotEqual (field string , value interface {}) string {
51
- escaped := Escape (field )
52
-
53
49
return c .Var (condBuilder {
54
50
Builder : func (ctx * argsCompileContext ) {
55
- ctx .WriteString (escaped )
51
+ ctx .WriteString (field )
56
52
ctx .WriteString (" <> " )
57
53
ctx .WriteValue (value )
58
54
},
@@ -71,11 +67,9 @@ func (c *Cond) NEQ(field string, value interface{}) string {
71
67
72
68
// GreaterThan is used to construct the expression "field > value".
73
69
func (c * Cond ) GreaterThan (field string , value interface {}) string {
74
- escaped := Escape (field )
75
-
76
70
return c .Var (condBuilder {
77
71
Builder : func (ctx * argsCompileContext ) {
78
- ctx .WriteString (escaped )
72
+ ctx .WriteString (field )
79
73
ctx .WriteString (" > " )
80
74
ctx .WriteValue (value )
81
75
},
@@ -94,11 +88,9 @@ func (c *Cond) GT(field string, value interface{}) string {
94
88
95
89
// GreaterEqualThan is used to construct the expression "field >= value".
96
90
func (c * Cond ) GreaterEqualThan (field string , value interface {}) string {
97
- escaped := Escape (field )
98
-
99
91
return c .Var (condBuilder {
100
92
Builder : func (ctx * argsCompileContext ) {
101
- ctx .WriteString (escaped )
93
+ ctx .WriteString (field )
102
94
ctx .WriteString (" >= " )
103
95
ctx .WriteValue (value )
104
96
},
@@ -117,11 +109,9 @@ func (c *Cond) GTE(field string, value interface{}) string {
117
109
118
110
// LessThan is used to construct the expression "field < value".
119
111
func (c * Cond ) LessThan (field string , value interface {}) string {
120
- escaped := Escape (field )
121
-
122
112
return c .Var (condBuilder {
123
113
Builder : func (ctx * argsCompileContext ) {
124
- ctx .WriteString (escaped )
114
+ ctx .WriteString (field )
125
115
ctx .WriteString (" < " )
126
116
ctx .WriteValue (value )
127
117
},
@@ -140,11 +130,9 @@ func (c *Cond) LT(field string, value interface{}) string {
140
130
141
131
// LessEqualThan is used to construct the expression "field <= value".
142
132
func (c * Cond ) LessEqualThan (field string , value interface {}) string {
143
- escaped := Escape (field )
144
-
145
133
return c .Var (condBuilder {
146
134
Builder : func (ctx * argsCompileContext ) {
147
- ctx .WriteString (escaped )
135
+ ctx .WriteString (field )
148
136
ctx .WriteString (" <= " )
149
137
ctx .WriteValue (value )
150
138
},
@@ -163,11 +151,9 @@ func (c *Cond) LTE(field string, value interface{}) string {
163
151
164
152
// In is used to construct the expression "field IN (value...)".
165
153
func (c * Cond ) In (field string , values ... interface {}) string {
166
- escaped := Escape (field )
167
-
168
154
return c .Var (condBuilder {
169
155
Builder : func (ctx * argsCompileContext ) {
170
- ctx .WriteString (escaped )
156
+ ctx .WriteString (field )
171
157
ctx .WriteString (" IN (" )
172
158
ctx .WriteValues (values , ", " )
173
159
ctx .WriteString (")" )
@@ -177,11 +163,9 @@ func (c *Cond) In(field string, values ...interface{}) string {
177
163
178
164
// NotIn is used to construct the expression "field NOT IN (value...)".
179
165
func (c * Cond ) NotIn (field string , values ... interface {}) string {
180
- escaped := Escape (field )
181
-
182
166
return c .Var (condBuilder {
183
167
Builder : func (ctx * argsCompileContext ) {
184
- ctx .WriteString (escaped )
168
+ ctx .WriteString (field )
185
169
ctx .WriteString (" NOT IN (" )
186
170
ctx .WriteValues (values , ", " )
187
171
ctx .WriteString (")" )
@@ -191,11 +175,9 @@ func (c *Cond) NotIn(field string, values ...interface{}) string {
191
175
192
176
// Like is used to construct the expression "field LIKE value".
193
177
func (c * Cond ) Like (field string , value interface {}) string {
194
- escaped := Escape (field )
195
-
196
178
return c .Var (condBuilder {
197
179
Builder : func (ctx * argsCompileContext ) {
198
- ctx .WriteString (escaped )
180
+ ctx .WriteString (field )
199
181
ctx .WriteString (" LIKE " )
200
182
ctx .WriteValue (value )
201
183
},
@@ -208,20 +190,18 @@ func (c *Cond) Like(field string, value interface{}) string {
208
190
// the ILike method will return "LOWER(field) LIKE LOWER(value)"
209
191
// to simulate the behavior of the ILIKE operator.
210
192
func (c * Cond ) ILike (field string , value interface {}) string {
211
- escaped := Escape (field )
212
-
213
193
return c .Var (condBuilder {
214
194
Builder : func (ctx * argsCompileContext ) {
215
195
switch ctx .Flavor {
216
196
case PostgreSQL , SQLite :
217
- ctx .WriteString (escaped )
197
+ ctx .WriteString (field )
218
198
ctx .WriteString (" ILIKE " )
219
199
ctx .WriteValue (value )
220
200
221
201
default :
222
202
// Use LOWER to simulate ILIKE.
223
203
ctx .WriteString ("LOWER(" )
224
- ctx .WriteString (escaped )
204
+ ctx .WriteString (field )
225
205
ctx .WriteString (") LIKE LOWER(" )
226
206
ctx .WriteValue (value )
227
207
ctx .WriteString (")" )
@@ -232,11 +212,9 @@ func (c *Cond) ILike(field string, value interface{}) string {
232
212
233
213
// NotLike is used to construct the expression "field NOT LIKE value".
234
214
func (c * Cond ) NotLike (field string , value interface {}) string {
235
- escaped := Escape (field )
236
-
237
215
return c .Var (condBuilder {
238
216
Builder : func (ctx * argsCompileContext ) {
239
- ctx .WriteString (escaped )
217
+ ctx .WriteString (field )
240
218
ctx .WriteString (" NOT LIKE " )
241
219
ctx .WriteValue (value )
242
220
},
@@ -249,20 +227,18 @@ func (c *Cond) NotLike(field string, value interface{}) string {
249
227
// the NotILike method will return "LOWER(field) NOT LIKE LOWER(value)"
250
228
// to simulate the behavior of the ILIKE operator.
251
229
func (c * Cond ) NotILike (field string , value interface {}) string {
252
- escaped := Escape (field )
253
-
254
230
return c .Var (condBuilder {
255
231
Builder : func (ctx * argsCompileContext ) {
256
232
switch ctx .Flavor {
257
233
case PostgreSQL , SQLite :
258
- ctx .WriteString (escaped )
234
+ ctx .WriteString (field )
259
235
ctx .WriteString (" NOT ILIKE " )
260
236
ctx .WriteValue (value )
261
237
262
238
default :
263
239
// Use LOWER to simulate ILIKE.
264
240
ctx .WriteString ("LOWER(" )
265
- ctx .WriteString (escaped )
241
+ ctx .WriteString (field )
266
242
ctx .WriteString (") NOT LIKE LOWER(" )
267
243
ctx .WriteValue (value )
268
244
ctx .WriteString (")" )
@@ -273,35 +249,29 @@ func (c *Cond) NotILike(field string, value interface{}) string {
273
249
274
250
// IsNull is used to construct the expression "field IS NULL".
275
251
func (c * Cond ) IsNull (field string ) string {
276
- escaped := Escape (field )
277
-
278
252
return c .Var (condBuilder {
279
253
Builder : func (ctx * argsCompileContext ) {
280
- ctx .WriteString (escaped )
254
+ ctx .WriteString (field )
281
255
ctx .WriteString (" IS NULL" )
282
256
},
283
257
})
284
258
}
285
259
286
260
// IsNotNull is used to construct the expression "field IS NOT NULL".
287
261
func (c * Cond ) IsNotNull (field string ) string {
288
- escaped := Escape (field )
289
-
290
262
return c .Var (condBuilder {
291
263
Builder : func (ctx * argsCompileContext ) {
292
- ctx .WriteString (escaped )
264
+ ctx .WriteString (field )
293
265
ctx .WriteString (" IS NOT NULL" )
294
266
},
295
267
})
296
268
}
297
269
298
270
// Between is used to construct the expression "field BETWEEN lower AND upper".
299
271
func (c * Cond ) Between (field string , lower , upper interface {}) string {
300
- escaped := Escape (field )
301
-
302
272
return c .Var (condBuilder {
303
273
Builder : func (ctx * argsCompileContext ) {
304
- ctx .WriteString (escaped )
274
+ ctx .WriteString (field )
305
275
ctx .WriteString (" BETWEEN " )
306
276
ctx .WriteValue (lower )
307
277
ctx .WriteString (" AND " )
@@ -312,11 +282,9 @@ func (c *Cond) Between(field string, lower, upper interface{}) string {
312
282
313
283
// NotBetween is used to construct the expression "field NOT BETWEEN lower AND upper".
314
284
func (c * Cond ) NotBetween (field string , lower , upper interface {}) string {
315
- escaped := Escape (field )
316
-
317
285
return c .Var (condBuilder {
318
286
Builder : func (ctx * argsCompileContext ) {
319
- ctx .WriteString (escaped )
287
+ ctx .WriteString (field )
320
288
ctx .WriteString (" NOT BETWEEN " )
321
289
ctx .WriteValue (lower )
322
290
ctx .WriteString (" AND " )
@@ -398,11 +366,9 @@ func (c *Cond) NotExists(subquery interface{}) string {
398
366
399
367
// Any is used to construct the expression "field op ANY (value...)".
400
368
func (c * Cond ) Any (field , op string , values ... interface {}) string {
401
- escaped := Escape (field )
402
-
403
369
return c .Var (condBuilder {
404
370
Builder : func (ctx * argsCompileContext ) {
405
- ctx .WriteString (escaped )
371
+ ctx .WriteString (field )
406
372
ctx .WriteString (" " )
407
373
ctx .WriteString (op )
408
374
ctx .WriteString (" ANY (" )
@@ -414,11 +380,9 @@ func (c *Cond) Any(field, op string, values ...interface{}) string {
414
380
415
381
// All is used to construct the expression "field op ALL (value...)".
416
382
func (c * Cond ) All (field , op string , values ... interface {}) string {
417
- escaped := Escape (field )
418
-
419
383
return c .Var (condBuilder {
420
384
Builder : func (ctx * argsCompileContext ) {
421
- ctx .WriteString (escaped )
385
+ ctx .WriteString (field )
422
386
ctx .WriteString (" " )
423
387
ctx .WriteString (op )
424
388
ctx .WriteString (" ALL (" )
@@ -430,11 +394,9 @@ func (c *Cond) All(field, op string, values ...interface{}) string {
430
394
431
395
// Some is used to construct the expression "field op SOME (value...)".
432
396
func (c * Cond ) Some (field , op string , values ... interface {}) string {
433
- escaped := Escape (field )
434
-
435
397
return c .Var (condBuilder {
436
398
Builder : func (ctx * argsCompileContext ) {
437
- ctx .WriteString (escaped )
399
+ ctx .WriteString (field )
438
400
ctx .WriteString (" " )
439
401
ctx .WriteString (op )
440
402
ctx .WriteString (" SOME (" )
@@ -451,19 +413,17 @@ func (c *Cond) Some(field, op string, values ...interface{}) string {
451
413
// "CASE ... WHEN ... ELSE ... END" expression to simulate the behavior of
452
414
// the IS DISTINCT FROM operator.
453
415
func (c * Cond ) IsDistinctFrom (field string , value interface {}) string {
454
- escaped := Escape (field )
455
-
456
416
return c .Var (condBuilder {
457
417
Builder : func (ctx * argsCompileContext ) {
458
418
switch ctx .Flavor {
459
419
case PostgreSQL , SQLite , SQLServer :
460
- ctx .WriteString (escaped )
420
+ ctx .WriteString (field )
461
421
ctx .WriteString (" IS DISTINCT FROM " )
462
422
ctx .WriteValue (value )
463
423
464
424
case MySQL :
465
425
ctx .WriteString ("NOT " )
466
- ctx .WriteString (escaped )
426
+ ctx .WriteString (field )
467
427
ctx .WriteString (" <=> " )
468
428
ctx .WriteValue (value )
469
429
@@ -474,15 +434,15 @@ func (c *Cond) IsDistinctFrom(field string, value interface{}) string {
474
434
// ELSE 1
475
435
// END = 1
476
436
ctx .WriteString ("CASE WHEN " )
477
- ctx .WriteString (escaped )
437
+ ctx .WriteString (field )
478
438
ctx .WriteString (" IS NULL AND " )
479
439
ctx .WriteValue (value )
480
440
ctx .WriteString (" IS NULL THEN 0 WHEN " )
481
- ctx .WriteString (escaped )
441
+ ctx .WriteString (field )
482
442
ctx .WriteString (" IS NOT NULL AND " )
483
443
ctx .WriteValue (value )
484
444
ctx .WriteString (" IS NOT NULL AND " )
485
- ctx .WriteString (escaped )
445
+ ctx .WriteString (field )
486
446
ctx .WriteString (" = " )
487
447
ctx .WriteValue (value )
488
448
ctx .WriteString (" THEN 0 ELSE 1 END = 1" )
@@ -498,18 +458,16 @@ func (c *Cond) IsDistinctFrom(field string, value interface{}) string {
498
458
// "CASE ... WHEN ... ELSE ... END" expression to simulate the behavior of
499
459
// the IS NOT DISTINCT FROM operator.
500
460
func (c * Cond ) IsNotDistinctFrom (field string , value interface {}) string {
501
- escaped := Escape (field )
502
-
503
461
return c .Var (condBuilder {
504
462
Builder : func (ctx * argsCompileContext ) {
505
463
switch ctx .Flavor {
506
464
case PostgreSQL , SQLite , SQLServer :
507
- ctx .WriteString (escaped )
465
+ ctx .WriteString (field )
508
466
ctx .WriteString (" IS NOT DISTINCT FROM " )
509
467
ctx .WriteValue (value )
510
468
511
469
case MySQL :
512
- ctx .WriteString (escaped )
470
+ ctx .WriteString (field )
513
471
ctx .WriteString (" <=> " )
514
472
ctx .WriteValue (value )
515
473
@@ -520,15 +478,15 @@ func (c *Cond) IsNotDistinctFrom(field string, value interface{}) string {
520
478
// ELSE 0
521
479
// END = 1
522
480
ctx .WriteString ("CASE WHEN " )
523
- ctx .WriteString (escaped )
481
+ ctx .WriteString (field )
524
482
ctx .WriteString (" IS NULL AND " )
525
483
ctx .WriteValue (value )
526
484
ctx .WriteString (" IS NULL THEN 1 WHEN " )
527
- ctx .WriteString (escaped )
485
+ ctx .WriteString (field )
528
486
ctx .WriteString (" IS NOT NULL AND " )
529
487
ctx .WriteValue (value )
530
488
ctx .WriteString (" IS NOT NULL AND " )
531
- ctx .WriteString (escaped )
489
+ ctx .WriteString (field )
532
490
ctx .WriteString (" = " )
533
491
ctx .WriteValue (value )
534
492
ctx .WriteString (" THEN 1 ELSE 0 END = 1" )
0 commit comments