不要怂,就是干,撸起袖子干!

Commit fa784c59 by Matt Broadstone

fixed a few more failing cases

  - missed a case for addLimitAndOffset for subqueries with a single model
  - formatResults should return undefined if there is no data
  - there are a few possible error messages in an invalid connection scenario
1 parent 03845fa5
...@@ -1236,10 +1236,16 @@ module.exports = (function() { ...@@ -1236,10 +1236,16 @@ module.exports = (function() {
if (options.order) { if (options.order) {
if (Array.isArray(options.order)) { if (Array.isArray(options.order)) {
options.order.forEach(function(t) { options.order.forEach(function(t) {
if (!Array.isArray(t)) {
if (isSubQuery && !(t instanceof Model) && !(t.model instanceof Model)) {
subQueryOrder.push(this.quote(t, model));
}
} else {
if (isSubQuery && !(t[0] instanceof Model) && !(t[0].model instanceof Model)) { if (isSubQuery && !(t[0] instanceof Model) && !(t[0].model instanceof Model)) {
subQueryOrder.push(this.quote(t, model)); subQueryOrder.push(this.quote(t, model));
} }
mainQueryOrder.push(this.quote(t, model)); mainQueryOrder.push(this.quote(t, model));
}
}.bind(this)); }.bind(this));
} else { } else {
mainQueryOrder.push(options.order); mainQueryOrder.push(options.order);
......
...@@ -113,11 +113,11 @@ module.exports = (function() { ...@@ -113,11 +113,11 @@ module.exports = (function() {
*/ */
Query.prototype.formatResults = function(data) { Query.prototype.formatResults = function(data) {
var result = this.callee; var result = this.callee;
if (data) {
if (this.isInsertQuery(data)) { if (this.isInsertQuery(data)) {
this.handleInsertQuery(data); this.handleInsertQuery(data);
} else if (this.isShowTableQuery()) { }
if (this.isShowTableQuery()) {
result = this.handleShowTableQuery(data); result = this.handleShowTableQuery(data);
} else if (this.isShowOrDescribeQuery()) { } else if (this.isShowOrDescribeQuery()) {
result = data; result = data;
...@@ -145,9 +145,6 @@ module.exports = (function() { ...@@ -145,9 +145,6 @@ module.exports = (function() {
} else if (this.isBulkDeleteQuery()){ } else if (this.isBulkDeleteQuery()){
result = data[0].AFFECTEDROWS; result = data[0].AFFECTEDROWS;
} }
} else if (!result) {
result = data;
}
return result; return result;
}; };
......
...@@ -113,23 +113,26 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -113,23 +113,26 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
.authenticate() .authenticate()
.complete(function(err, result) { .complete(function(err, result) {
if (dialect === 'mariadb') { if (dialect === 'mariadb') {
expect(err.message).to.match(/Access denied for user/) expect(err.message).to.match(/Access denied for user/);
} else if (dialect === 'postgres') { } else if (dialect === 'postgres') {
expect( expect(
err.message.match(/connect ECONNREFUSED/) || err.message.match(/connect ECONNREFUSED/) ||
err.message.match(/invalid port number/) err.message.match(/invalid port number/)
).to.be.ok ).to.be.ok;
} else if (dialect === 'mssql'){ } else if (dialect === 'mssql'){
expect(err.message.match(/ConnectionError: Login failed for user/)).to.be.ok expect(
err.message.match(/ConnectionError: Login failed for user/) ||
err.message.match(/RangeError: Port should be > 0 and < 65536/)
).to.be.ok;
} else { } else {
expect(err.message).to.match(/connect ECONNREFUSED/) expect(err.message).to.match(/connect ECONNREFUSED/)
} }
done() done();
}) });
}) });
}) });
describe('with invalid credentials', function() { describe('with invalid credentials', function() {
beforeEach(function() { beforeEach(function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!