Reputation: 962
I am finding some odd behaviour. When I include a certain where clause, the query does not return at all. . .
var query = "SELECT id FROM tbl_jobs WHERE jobSiteId = "+site.id+/*" AND jobStartStamp > "+start_stamp +*/" ORDER BY jobStartStamp ASC LIMIT 1";
//sails.log.error(query);
Visit.query(query,function(err, visit){
if (err) {
sails.log.error(err);
return res.serverError(err);
}
return res.send(visit);
});
//Visit.find({site:site.id, start:{">",start_stamp}).sort({start:"ASC"}).limit.exec
... doesn't work
When I comment out the 'jobStartStamp' where clause, the query returns fine. When I put it back in, it doesn't call the callback. I do not get any errors on the sails console.
When I execute the query (with the entire where clause) in phpMyAdmin, I get a response (<1 second).
Any ideas how to find out why this is happening?
Upvotes: 1
Views: 320
Reputation: 1010
Are you running against the same DB in both instances, or is one DB on your server and another on your desktop? If data returns with "<" rather than ">" it indicates that your server has jobStartStamp at an earlier date/time than start_stamp.
Is the Visit callback not being called, or is it getting a null resultset from the query?
Upvotes: 1