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

Commit 46abbe88 by Mick Hansen

[fix] fix case with order: sequelize.literal(), closes #2838

1 parent 4dd3f181
# Next
- [BUG] Fixed issue with `order: sequelize.literal('string')`
# 2.0.0-rc6
- [BUG] Fixed issue with including by association reference and where
......
......@@ -1231,7 +1231,7 @@ module.exports = (function() {
mainQueryOrder.push(this.quote(t, model));
}.bind(this));
} else {
mainQueryOrder.push(options.order);
mainQueryOrder.push(this.quote(options.order, model));
}
if (mainQueryOrder.length) {
......
'use strict';
var chai = require('chai')
, Sequelize = require('../../../index')
, expect = chai.expect
, Support = require(__dirname + '/../../support')
, DataTypes = require(__dirname + '/../../../lib/data-types')
, dialect = Support.getTestDialect()
, config = require(__dirname + '/../../config/config')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')
, current = Support.sequelize;
chai.use(datetime);
chai.config.includeStack = true;
describe(Support.getTestDialectTeaser('Model'), function() {
describe('findAll', function () {
describe('order', function () {
describe('Sequelize.literal()', function () {
beforeEach(function () {
this.User = this.sequelize.define('User', {
email: DataTypes.STRING
});
return this.User.sync({force: true}).bind(this).then(function () {
return this.User.create({
email: 'test@sequelizejs.com'
});
});
});
it('should work with order: literal()', function () {
return this.User.findAll({
order: this.sequelize.literal('email IS NOT NULL')
}).then(function (users) {
expect(users.length).to.equal(1);
users.forEach(function (user) {
expect(user.get('email')).to.be.ok;
});
});
});
it('should work with order: [literal()]', function () {
return this.User.findAll({
order: [this.sequelize.literal('email IS NOT NULL')]
}).then(function (users) {
expect(users.length).to.equal(1);
users.forEach(function (user) {
expect(user.get('email')).to.be.ok;
});
});
});
it('should work with order: [[literal()]]', function () {
return this.User.findAll({
order: [
[this.sequelize.literal('email IS NOT NULL')]
]
}).then(function (users) {
expect(users.length).to.equal(1);
users.forEach(function (user) {
expect(user.get('email')).to.be.ok;
});
});
});
});
});
});
});
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!