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