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

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 () { ...@@ -389,7 +389,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]} ]}
], ],
order: [ order: [
['User.id', 'ASC'] ['id', 'ASC']
] ]
}).done(function (err, users) { }).done(function (err, users) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -780,8 +780,8 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -780,8 +780,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
{model: Tag} {model: Tag}
], ],
order: [ order: [
['Product.id', 'ASC'], ['id', 'ASC'],
['Tags.id', 'ASC'] [Tag, 'id', 'ASC']
] ]
}).done(function (err, products) { }).done(function (err, products) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]} ]}
], ],
order: [ order: [
['User.id', 'ASC'] ['id', 'ASC']
] ]
}).done(function (err, users) { }).done(function (err, users) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -1709,7 +1709,7 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -1709,7 +1709,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
], ],
limit: 6, limit: 6,
order: [ order: [
['Product.id', 'ASC'] ['id', 'ASC']
] ]
}).done(function (err, products) { }).done(function (err, products) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -1739,7 +1739,7 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -1739,7 +1739,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
], ],
limit: 10, limit: 10,
order: [ order: [
['Product.id', 'ASC'] ['id', 'ASC']
] ]
}).done(function (err, products) { }).done(function (err, products) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
......
...@@ -680,8 +680,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -680,8 +680,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
{model: Tag} {model: Tag}
], ],
order: [ order: [
['Product.id', 'ASC'], ['id', 'ASC'],
['Tags.id', 'ASC'] [Tag, 'id', 'ASC']
] ]
}).done(function (err, products) { }).done(function (err, products) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -1316,7 +1316,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -1316,7 +1316,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
]} ]}
], ],
order: [ order: [
['User.id', 'ASC'] ['id', 'ASC']
] ]
}).done(function (err, users) { }).done(function (err, users) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -1401,7 +1401,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -1401,7 +1401,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
], ],
limit: 3, limit: 3,
order: [ order: [
[self.models.Product.name+'.id', 'ASC'] ['id', 'ASC']
] ]
}).done(function (err, products) { }).done(function (err, products) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -1430,7 +1430,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -1430,7 +1430,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
], ],
limit: 6, limit: 6,
order: [ order: [
['Product.id', 'ASC'] ['id', 'ASC']
] ]
}).done(function (err, products) { }).done(function (err, products) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -1460,7 +1460,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
], ],
limit: 10, limit: 10,
order: [ order: [
['Product.id', 'ASC'] ['id', 'ASC']
] ]
}).done(function (err, products) { }).done(function (err, products) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
......
...@@ -163,9 +163,10 @@ if (Support.dialectIsMySQL()) { ...@@ -163,9 +163,10 @@ if (Support.dialectIsMySQL()) {
expectation: "SELECT * FROM `myTable` ORDER BY `myTable`.`id`;", expectation: "SELECT * FROM `myTable` ORDER BY `myTable`.`id`;",
context: QueryGenerator context: QueryGenerator
}, { }, {
arguments: ['myTable', {order: [["id", 'DESC']]}], arguments: ['myTable', {order: [["id", 'DESC']]}, function(sequelize) {return sequelize.define('myTable', {});}],
expectation: "SELECT * FROM `myTable` ORDER BY `id` DESC;", expectation: "SELECT * FROM `myTable` AS `myTable` ORDER BY `myTable`.`id` DESC;",
context: QueryGenerator context: QueryGenerator,
needsSequelize: true
}, { }, {
title: 'raw arguments are neither quoted nor escaped', title: 'raw arguments are neither quoted nor escaped',
arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'}, 'DESC']]}], arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'}, 'DESC']]}],
...@@ -588,7 +589,8 @@ if (Support.dialectIsMySQL()) { ...@@ -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 // 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: {}}; var context = test.context || {options: {}};
if (test.needsSequelize) { 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.options = context.options;
QueryGenerator._dialect = this.sequelize.dialect; QueryGenerator._dialect = this.sequelize.dialect;
......
...@@ -249,9 +249,10 @@ if (dialect.match(/^postgres/)) { ...@@ -249,9 +249,10 @@ if (dialect.match(/^postgres/)) {
expectation: 'SELECT * FROM "myTable" ORDER BY "myTable"."id";', expectation: 'SELECT * FROM "myTable" ORDER BY "myTable"."id";',
context: QueryGenerator context: QueryGenerator
}, { }, {
arguments: ['myTable', {order: [["id", 'DESC']]}], arguments: ['myTable', {order: [["id", 'DESC']]}, function(sequelize) {return sequelize.define('myTable', {});}],
expectation: 'SELECT * FROM "myTable" ORDER BY "id" DESC;', expectation: 'SELECT * FROM "myTable" AS "myTable" ORDER BY "myTable"."id" DESC;',
context: QueryGenerator context: QueryGenerator,
needsSequelize: true
}, { }, {
title: 'raw arguments are neither quoted nor escaped', title: 'raw arguments are neither quoted nor escaped',
arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'},'DESC']]}], arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'},'DESC']]}],
...@@ -984,7 +985,8 @@ if (dialect.match(/^postgres/)) { ...@@ -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 // 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: {}}; var context = test.context || {options: {}};
if (test.needsSequelize) { 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.options = context.options;
QueryGenerator._dialect = this.sequelize.dialect; QueryGenerator._dialect = this.sequelize.dialect;
......
...@@ -154,9 +154,10 @@ if (dialect === 'sqlite') { ...@@ -154,9 +154,10 @@ if (dialect === 'sqlite') {
expectation: "SELECT * FROM `myTable` ORDER BY `myTable`.`id`;", expectation: "SELECT * FROM `myTable` ORDER BY `myTable`.`id`;",
context: QueryGenerator context: QueryGenerator
}, { }, {
arguments: ['myTable', {order: [["id", 'DESC']]}], arguments: ['myTable', {order: [["id", 'DESC']]}, function(sequelize) {return sequelize.define('myTable', {});}],
expectation: "SELECT * FROM `myTable` ORDER BY `id` DESC;", expectation: "SELECT * FROM `myTable` AS `myTable` ORDER BY `myTable`.`id` DESC;",
context: QueryGenerator context: QueryGenerator,
needsSequelize: true
}, { }, {
title: 'raw arguments are neither quoted nor escaped', title: 'raw arguments are neither quoted nor escaped',
arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'}, 'DESC']]}], arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'}, 'DESC']]}],
...@@ -536,7 +537,8 @@ if (dialect === 'sqlite') { ...@@ -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 // 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: {}}; var context = test.context || {options: {}};
if (test.needsSequelize) { 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.options = context.options;
QueryGenerator._dialect = this.sequelize.dialect; 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!