node.js - Tedious or Sequelize uses the wrong syntax for `findOne()` -
i using sequelize tedious access sql server 2008.
when sequelizemodel.findone() exception -
unhandled rejection sequelizedatabaseerror: invalid usage of option next in fetch statement.
i know sql server 2008 doesn't support offset 0 rows fetch next 1 rows only , why exception thrown.
but have explicitly set tdsversion in tedious options 7_3_b.
as described here -
http://pekim.github.io/tedious/api-connection.html
i've tried tds versions , query syntax generated contains fetch/next syntax.
am missing something?
shouldn't syntax specific tds version?
i've verified tdsversion option being passed tedious connection library sequelize.
example of query syntax generated -
select [id], [first_name], [last_name] [users] [users] order [id] offset 0 rows fetch next 1 rows only;
this issue in sequelize -- uses offset fetch syntax, supported in sql server 2012 , newer.
i submitted issue on github: https://github.com/sequelize/sequelize/issues/4404
the issue affects findbyid method. workaround method use findall where specify id, , use first element returned array:
thing.findall({ where: {id: id} }).then( function(things) { if (things.length == 0) { // handle error } dosomething(things[0]) }).catch( function(err) { // handle error });
Comments
Post a Comment