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

Commit a6cdcdd4 by overlookmotel

Alter tests for add table name to order/group

1 parent ed9e98cf
......@@ -389,7 +389,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]}
],
order: [
['User.id', 'ASC']
['id', 'ASC']
]
}).done(function (err, users) {
expect(err).not.to.be.ok
......@@ -780,8 +780,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
{model: Tag}
],
order: [
['Product.id', 'ASC'],
['Tags.id', 'ASC']
['id', 'ASC'],
[Tag, 'id', 'ASC']
]
}).done(function (err, products) {
expect(err).not.to.be.ok
......@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]}
],
order: [
['User.id', 'ASC']
['id', 'ASC']
]
}).done(function (err, users) {
expect(err).not.to.be.ok
......@@ -1709,7 +1709,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
],
limit: 6,
order: [
['Product.id', 'ASC']
['id', 'ASC']
]
}).done(function (err, products) {
expect(err).not.to.be.ok
......@@ -1739,7 +1739,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
],
limit: 10,
order: [
['Product.id', 'ASC']
['id', 'ASC']
]
}).done(function (err, products) {
expect(err).not.to.be.ok
......
......@@ -680,8 +680,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
{model: Tag}
],
order: [
['Product.id', 'ASC'],
['Tags.id', 'ASC']
['id', 'ASC'],
[Tag, 'id', 'ASC']
]
}).done(function (err, products) {
expect(err).not.to.be.ok
......@@ -1316,7 +1316,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
]}
],
order: [
['User.id', 'ASC']
['id', 'ASC']
]
}).done(function (err, users) {
expect(err).not.to.be.ok
......@@ -1401,7 +1401,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
],
limit: 3,
order: [
[self.models.Product.name+'.id', 'ASC']
['id', 'ASC']
]
}).done(function (err, products) {
expect(err).not.to.be.ok
......@@ -1430,7 +1430,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
],
limit: 6,
order: [
['Product.id', 'ASC']
['id', 'ASC']
]
}).done(function (err, products) {
expect(err).not.to.be.ok
......@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
],
limit: 10,
order: [
['Product.id', 'ASC']
['id', 'ASC']
]
}).done(function (err, products) {
expect(err).not.to.be.ok
......
......@@ -163,9 +163,10 @@ if (Support.dialectIsMySQL()) {
expectation: "SELECT * FROM `myTable` ORDER BY `myTable`.`id`;",
context: QueryGenerator
}, {
arguments: ['myTable', {order: [["id", 'DESC']]}],
expectation: "SELECT * FROM `myTable` ORDER BY `id` DESC;",
context: QueryGenerator
arguments: ['myTable', {order: [["id", 'DESC']]}, function(sequelize) {return sequelize.define('myTable', {});}],
expectation: "SELECT * FROM `myTable` AS `myTable` ORDER BY `myTable`.`id` DESC;",
context: QueryGenerator,
needsSequelize: true
}, {
title: 'raw arguments are neither quoted nor escaped',
arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'}, 'DESC']]}],
......@@ -588,7 +589,8 @@ if (Support.dialectIsMySQL()) {
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
var context = test.context || {options: {}};
if (test.needsSequelize) {
test.arguments[1] = test.arguments[1](this.sequelize);
if (_.isFunction(test.arguments[1])) test.arguments[1] = test.arguments[1](this.sequelize);
if (_.isFunction(test.arguments[2])) test.arguments[2] = test.arguments[2](this.sequelize);
}
QueryGenerator.options = context.options;
QueryGenerator._dialect = this.sequelize.dialect;
......
......@@ -249,9 +249,10 @@ if (dialect.match(/^postgres/)) {
expectation: 'SELECT * FROM "myTable" ORDER BY "myTable"."id";',
context: QueryGenerator
}, {
arguments: ['myTable', {order: [["id", 'DESC']]}],
expectation: 'SELECT * FROM "myTable" ORDER BY "id" DESC;',
context: QueryGenerator
arguments: ['myTable', {order: [["id", 'DESC']]}, function(sequelize) {return sequelize.define('myTable', {});}],
expectation: 'SELECT * FROM "myTable" AS "myTable" ORDER BY "myTable"."id" DESC;',
context: QueryGenerator,
needsSequelize: true
}, {
title: 'raw arguments are neither quoted nor escaped',
arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'},'DESC']]}],
......@@ -984,7 +985,8 @@ if (dialect.match(/^postgres/)) {
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
var context = test.context || {options: {}};
if (test.needsSequelize) {
test.arguments[1] = test.arguments[1](this.sequelize);
if (_.isFunction(test.arguments[1])) test.arguments[1] = test.arguments[1](this.sequelize);
if (_.isFunction(test.arguments[2])) test.arguments[2] = test.arguments[2](this.sequelize);
}
QueryGenerator.options = context.options;
QueryGenerator._dialect = this.sequelize.dialect;
......
......@@ -154,9 +154,10 @@ if (dialect === 'sqlite') {
expectation: "SELECT * FROM `myTable` ORDER BY `myTable`.`id`;",
context: QueryGenerator
}, {
arguments: ['myTable', {order: [["id", 'DESC']]}],
expectation: "SELECT * FROM `myTable` ORDER BY `id` DESC;",
context: QueryGenerator
arguments: ['myTable', {order: [["id", 'DESC']]}, function(sequelize) {return sequelize.define('myTable', {});}],
expectation: "SELECT * FROM `myTable` AS `myTable` ORDER BY `myTable`.`id` DESC;",
context: QueryGenerator,
needsSequelize: true
}, {
title: 'raw arguments are neither quoted nor escaped',
arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'}, 'DESC']]}],
......@@ -536,7 +537,8 @@ if (dialect === 'sqlite') {
// Options would normally be set by the query interface that instantiates the query-generator, but here we specify it explicitly
var context = test.context || {options: {}};
if (test.needsSequelize) {
test.arguments[1] = test.arguments[1](this.sequelize);
if (_.isFunction(test.arguments[1])) test.arguments[1] = test.arguments[1](this.sequelize);
if (_.isFunction(test.arguments[2])) test.arguments[2] = test.arguments[2](this.sequelize);
}
QueryGenerator.options = context.options;
QueryGenerator._dialect = this.sequelize.dialect;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!