@@ -215,6 +215,121 @@ describe('postgresql connector', function() {
215
215
} ) ;
216
216
} ) ;
217
217
218
+ context ( 'pattern matching operators' , function ( ) {
219
+ before ( function deleteTestFixtures ( done ) {
220
+ Post . destroyAll ( done ) ;
221
+ } ) ;
222
+ before ( function createTextFixtures ( done ) {
223
+ Post . create ( [ {
224
+ title : 't1' ,
225
+ content : 'T1_TestCase' ,
226
+ } , {
227
+ title : 't2' ,
228
+ content : 'T2_TheOtherCase' ,
229
+ } ] , done ) ;
230
+ } ) ;
231
+ after ( function deleteTestFixtures ( done ) {
232
+ Post . destroyAll ( done ) ;
233
+ } ) ;
234
+
235
+ it ( 'should support case sensitive queries using like' ,
236
+ function ( done ) {
237
+ Post . find ( { where : { content : { like : '%TestCase%' } } } ,
238
+ function ( err , posts ) {
239
+ should . not . exists ( err ) ;
240
+ posts . length . should . equal ( 1 ) ;
241
+ posts [ 0 ] . content . should . equal ( 'T1_TestCase' ) ;
242
+ done ( ) ;
243
+ } ) ;
244
+ } ) ;
245
+
246
+ it ( 'should not support case insensitive queries using like' ,
247
+ function ( done ) {
248
+ Post . find ( { where : { content : { like : '%tesTcasE%' } } } ,
249
+ function ( err , posts ) {
250
+ should . not . exists ( err ) ;
251
+ posts . length . should . equal ( 0 ) ;
252
+ done ( ) ;
253
+ } ) ;
254
+ } ) ;
255
+
256
+ it ( 'should support like for no match' , function ( done ) {
257
+ Post . find ( { where : { content : { like : '%TestXase%' } } } ,
258
+ function ( err , posts ) {
259
+ should . not . exists ( err ) ;
260
+ posts . length . should . equal ( 0 ) ;
261
+ done ( ) ;
262
+ } ) ;
263
+ } ) ;
264
+
265
+ it ( 'should support negative case sensitive queries using nlike' ,
266
+ function ( done ) {
267
+ Post . find ( { where : { content : { nlike : '%Case%' } } } ,
268
+ function ( err , posts ) {
269
+ should . not . exists ( err ) ;
270
+ posts . length . should . equal ( 0 ) ;
271
+ done ( ) ;
272
+ } ) ;
273
+ } ) ;
274
+
275
+ it ( 'should not support negative case insensitive queries using nlike' ,
276
+ function ( done ) {
277
+ Post . find ( { where : { content : { nlike : '%casE%' } } } ,
278
+ function ( err , posts ) {
279
+ should . not . exists ( err ) ;
280
+ posts . length . should . equal ( 2 ) ;
281
+ done ( ) ;
282
+ } ) ;
283
+ } ) ;
284
+
285
+ it ( 'should support nlike for no match' , function ( done ) {
286
+ Post . find ( { where : { content : { nlike : '%TestXase%' } } } ,
287
+ function ( err , posts ) {
288
+ should . not . exists ( err ) ;
289
+ posts . length . should . equal ( 2 ) ;
290
+ done ( ) ;
291
+ } ) ;
292
+ } ) ;
293
+
294
+ it ( 'should support case insensitive queries using ilike' , function ( done ) {
295
+ Post . find ( { where : { content : { ilike : '%tesTcasE%' } } } ,
296
+ function ( err , posts ) {
297
+ should . not . exist ( err ) ;
298
+ posts . length . should . equal ( 1 ) ;
299
+ posts [ 0 ] . content . should . equal ( 'T1_TestCase' ) ;
300
+ done ( ) ;
301
+ } ) ;
302
+ } ) ;
303
+
304
+ it ( 'should support ilike for no match' , function ( done ) {
305
+ Post . find ( { where : { content : { ilike : '%tesTxasE%' } } } ,
306
+ function ( err , posts ) {
307
+ should . not . exists ( err ) ;
308
+ posts . length . should . equal ( 0 ) ;
309
+ done ( ) ;
310
+ } ) ;
311
+ } ) ;
312
+
313
+ it ( 'should support negative case insensitive queries using nilike' ,
314
+ function ( done ) {
315
+ Post . find ( { where : { content : { nilike : '%casE%' } } } ,
316
+ function ( err , posts ) {
317
+ should . not . exist ( err ) ;
318
+ posts . length . should . equal ( 0 ) ;
319
+ done ( ) ;
320
+ } ) ;
321
+ } ) ;
322
+
323
+ it ( 'should support nilike for no match' , function ( done ) {
324
+ Post . find ( { where : { content : { nilike : '%tesTxasE%' } } } ,
325
+ function ( err , posts ) {
326
+ should . not . exists ( err ) ;
327
+ posts . length . should . equal ( 2 ) ;
328
+ done ( ) ;
329
+ } ) ;
330
+ } ) ;
331
+ } ) ;
332
+
218
333
context ( 'regexp operator' , function ( ) {
219
334
before ( function deleteTestFixtures ( done ) {
220
335
Post . destroyAll ( done ) ;
0 commit comments