From 4c8e4d8e4d6586b7c0659f5943591306eb5fb859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Drouyer?= Date: Sat, 3 Nov 2012 15:25:15 +0100 Subject: [PATCH] fixed regression for postgres --- test/common_test.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/test/common_test.js b/test/common_test.js index 5356b81c..c1c7c740 100644 --- a/test/common_test.js +++ b/test/common_test.js @@ -452,8 +452,17 @@ function testOrm(schema) { if (schema.name !== 'mongodb') it('hasMany should support additional conditions', function (test) { + + // We try to get the first post with a userId != NULL + var search = {}; + if (schema.name === 'mongodb') { // On mongodb, complex conditions are not supported + search = {order: 'userId DESC'}; + } else { + search = {where: {userId: {'gt': 0}}}; + } + // Finding one post with an existing author associated - Post.findOne({order: 'userId DESC'}, function (err, post) { + Post.findOne(search, function (err, post) { // We could get the user with belongs to relationship but it is better if there is no interactions. User.find(post.userId, function(err, user) { user.posts({where: {id: post.id}}, function(err, posts) { @@ -466,8 +475,16 @@ function testOrm(schema) { it('hasMany should be cached', function (test) { + // We try to get the first post with a userId != NULL + var search = {}; + if (schema.name === 'mongodb') { // On mongodb, complex conditions are not supported + search = {order: 'userId DESC'}; + } else { + search = {where: {userId: {'gt': 0}}}; + } + // Finding one post with an existing author associated - Post.findOne({order: 'userId DESC'}, function (err, post) { + Post.findOne(search, function (err, post) { // We could get the user with belongs to relationship but it is better if there is no interactions. User.find(post.userId, function(err, user) { User.create(function(err, voidUser) { @@ -486,7 +503,6 @@ function testOrm(schema) { test.done(); } else { user.posts({where: {id: data[0].id}}, function(err, data) { - console.log('data2', data); test.equal(data.length, 1, 'There should be only one post.'); requestsAreCounted && test.equal(nbInitialRequests + 1, nbSchemaRequests, 'There should be one additional request since we added conditions.');