diff --git a/test/integration/suite/querying.test.js b/test/integration/suite/querying.test.js index e6c0ebc1..781efb5a 100644 --- a/test/integration/suite/querying.test.js +++ b/test/integration/suite/querying.test.js @@ -538,7 +538,7 @@ describe('=> Group / Join / Subqueries', function() { // https://github.com/cyjake/leoric/issues/417 // SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `comments`.`article_id` = `posts`.`id` WHERE `posts`.`gmt_deleted` IS NULL assert.equal(Post.find().join(Comment, 'comments.articleId = posts.id').toSqlString(), Post.include('comments').toSqlString()); - const posts = await Post.find().join(Comment, 'comments.articleId = posts.id'); + const posts = await Post.find().join(Comment, 'comments.articleId = posts.id').order('posts.id'); assert.equal(posts.length, 4); assert.equal(posts[0].comments.length, 0); @@ -552,14 +552,14 @@ describe('=> Group / Join / Subqueries', function() { // https://github.com/cyjake/leoric/issues/417 const posts = await Post.find().limit(1).join(Comment, 'comments.articleId = posts.id').where({ 'posts.title': { $like: 'Archb%' }, - }); + }).order('posts.id'); assert.equal(posts.length, 1); assert.ok(posts[0].comments[0] instanceof Comment); }); it('Bone.find().join() without association', async function() { // https://github.com/cyjake/leoric/issues/417 - const posts = await Post.find().join(User, 'posts.authorId = users.id'); + const posts = await Post.find().join(User, 'posts.authorId = users.id').order('posts.id'); assert.equal(posts.length, 4); assert.ok(posts[0].users); @@ -570,7 +570,7 @@ describe('=> Group / Join / Subqueries', function() { // https://github.com/cyjake/leoric/issues/417 const posts = await Post.find().limit(1).join(User, 'posts.authorId = users.id').where({ 'posts.title': { $like: 'Archb%' }, - }); + }).order('posts.id'); assert.equal(posts.length, 1); assert.ok(posts[0].users instanceof User); }); diff --git a/test/unit/spell.test.js b/test/unit/spell.test.js index 060be49d..1d1ab159 100644 --- a/test/unit/spell.test.js +++ b/test/unit/spell.test.js @@ -587,7 +587,7 @@ describe('=> Spell', function() { it('arbitrary join', function() { assert.equal( Post.join(Comment, 'comments.articleId = posts.id').toString(), - 'SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `comments`.`article_id` = `posts`.`id` WHERE `posts`.`gmt_deleted` IS NULL' + 'SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `posts`.`id` = `comments`.`article_id` AND `comments`.`gmt_deleted` IS NULL WHERE `posts`.`gmt_deleted` IS NULL' ); assert.equal(Post.include('comments').limit(1).toSqlString(), heresql(function () { @@ -615,7 +615,7 @@ describe('=> Spell', function() { assert.equal( Post.join(Comment, 'comments.articleId = posts.id').limit(1).toString(), - 'SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `comments`.`article_id` = `posts`.`id` WHERE `posts`.`gmt_deleted` IS NULL LIMIT 1' + 'SELECT `posts`.*, `comments`.* FROM `articles` AS `posts` LEFT JOIN `comments` AS `comments` ON `posts`.`id` = `comments`.`article_id` AND `comments`.`gmt_deleted` IS NULL WHERE `posts`.`gmt_deleted` IS NULL LIMIT 1' ); }); diff --git a/tsconfig.json b/tsconfig.json index 1b3ae529..a051bab9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,8 @@ "target": "ES2020", }, "include": [ - "src/**/*" + "src/**/*", + "test/**/*.ts" ], "exclude": [ "dist",