You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/mongo-knex/test/unit/convertor.test.js
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -407,6 +407,30 @@ describe('Relations', function () {
407
407
runQuery({'posts_meta.meta_title': {$ne: 'Meta of A Whole New World'}})
408
408
.should.eql('select * from `posts` where `posts`.`id` not in (select `posts`.`id` from `posts` left join `posts_meta` on `posts_meta`.`post_id` = `posts`.`id` where `posts_meta`.`meta_title` in (\'Meta of A Whole New World\'))');
409
409
});
410
+
411
+
it('should be able to perform a match query on a one-to-one relation',function(){
412
+
constinnerQuery='select `posts`.`id` from `posts` left join `posts_meta` on `posts_meta`.`post_id` = `posts`.`id` where lower(`posts_meta`.`meta_title`) like \'%world%\' ESCAPE \'*\'';
.should.eql(`select * from \`posts\` where \`posts\`.\`id\` in (${innerQuery})`);
415
+
});
416
+
417
+
it('should be able to perform a negated match query on a one-to-one relation',function(){
418
+
constinnerQuery='select `posts`.`id` from `posts` left join `posts_meta` on `posts_meta`.`post_id` = `posts`.`id` where lower(`posts_meta`.`meta_title`) not like \'%world%\' ESCAPE \'*\'';
.should.eql(`select * from \`posts\` where \`posts\`.\`id\` in (${innerQuery})`);
421
+
});
422
+
423
+
it('should be able to perform a match query on a many-to-many relation',function(){
424
+
constinnerQuery='select `posts_tags`.`post_id` from `posts_tags` inner join `tags` on `tags`.`id` = `posts_tags`.`tag_id` where `tags`.`name` like \'%wor*%ld%\' ESCAPE \'*\'';
425
+
runQuery({'tags.name': {$regex: /wor%ld/}})
426
+
.should.eql(`select * from \`posts\` where \`posts\`.\`id\` in (${innerQuery})`);
427
+
});
428
+
429
+
it('should be able to perform a negated match query on a many-to-many relation',function(){
430
+
constinnerQuery='select `posts_tags`.`post_id` from `posts_tags` inner join `tags` on `tags`.`id` = `posts_tags`.`tag_id` where `tags`.`name` not like \'%wor*%ld%\' ESCAPE \'*\'';
431
+
runQuery({'tags.name': {$not: /wor%ld/}})
432
+
.should.eql(`select * from \`posts\` where \`posts\`.\`id\` in (${innerQuery})`);
0 commit comments