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

Commit 15e961e5 by Mick Hansen

fix more tests, again

1 parent 4df0e8e9
...@@ -1287,8 +1287,8 @@ module.exports = (function() { ...@@ -1287,8 +1287,8 @@ module.exports = (function() {
return options return options
} }
if(this.tableName) { if(this.name || this.tableName) {
quoteIdentifiedDeletedAtCol = this.QueryInterface.quoteIdentifier(this.tableName) + '.' + quoteIdentifiedDeletedAtCol quoteIdentifiedDeletedAtCol = this.QueryInterface.quoteIdentifier(this.name || this.tableName) + '.' + quoteIdentifiedDeletedAtCol
} }
if (typeof options.where === "string") { if (typeof options.where === "string") {
......
...@@ -986,6 +986,9 @@ module.exports = (function() { ...@@ -986,6 +986,9 @@ module.exports = (function() {
if (Array.isArray(tableName)) { if (Array.isArray(tableName)) {
tableName = tableName[0] tableName = tableName[0]
if (Array.isArray(tableName)) {
tableName = tableName[1]
}
} }
options = options || {} options = options || {}
......
...@@ -1937,17 +1937,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1937,17 +1937,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
var tableName = '' var tableName = ''
, ident = this.sequelize.queryInterface.QueryGenerator.quoteIdentifier , ident = this.sequelize.queryInterface.QueryGenerator.quoteIdentifier
, escape = this.sequelize.queryInterface.QueryGenerator.escape , escape = this.sequelize.queryInterface.QueryGenerator.escape
if(this.Project.name) {
tableName = ident(this.Project.name) + '.'
}
this.User.findAll({ this.User.findAll({
where: [ where: [
tableName + ident('title') + ' = ' + escape('republic') this.sequelize.queryInterface.QueryGenerator.quoteIdentifiers('Projects.title') + ' = ' + escape('republic')
], ],
include: [ include: [
{model: this.Project} {model: this.Project}
] ]
}).success(function(users){ }).done(function(err, users){
expect(err).not.to.be.ok
try{ try{
expect(users.length).to.be.equal(1) expect(users.length).to.be.equal(1)
...@@ -1956,7 +1955,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1956,7 +1955,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}catch(e){ }catch(e){
done(e) done(e)
} }
}).error(done) })
}) })
it('should not overwrite a specified deletedAt', function(done) { it('should not overwrite a specified deletedAt', function(done) {
......
...@@ -767,10 +767,10 @@ if (dialect.match(/^postgres/)) { ...@@ -767,10 +767,10 @@ if (dialect.match(/^postgres/)) {
arguments: ['myTable', {name: "foo';DROP TABLE myTable;"}, {limit: 10}], arguments: ['myTable', {name: "foo';DROP TABLE myTable;"}, {limit: 10}],
expectation: "DELETE FROM \"myTable\" WHERE \"id\" IN (SELECT \"id\" FROM \"myTable\" WHERE \"name\"='foo'';DROP TABLE myTable;' LIMIT 10)" expectation: "DELETE FROM \"myTable\" WHERE \"id\" IN (SELECT \"id\" FROM \"myTable\" WHERE \"name\"='foo'';DROP TABLE myTable;' LIMIT 10)"
}, { }, {
arguments: [{schema: 'mySchema', tableName: 'myTable'}, {name: 'foo'}], arguments: ['mySchema.myTable', {name: 'foo'}],
expectation: "DELETE FROM \"mySchema\".\"myTable\" WHERE \"id\" IN (SELECT \"id\" FROM \"mySchema\".\"myTable\" WHERE \"name\"='foo' LIMIT 1)" expectation: "DELETE FROM \"mySchema\".\"myTable\" WHERE \"id\" IN (SELECT \"id\" FROM \"mySchema\".\"myTable\" WHERE \"name\"='foo' LIMIT 1)"
}, { }, {
arguments: [{schema: 'mySchema', tableName: 'myTable'}, {name: "foo';DROP TABLE mySchema.myTable;"}, {limit: 10}], arguments: ['mySchema.myTable', {name: "foo';DROP TABLE mySchema.myTable;"}, {limit: 10}],
expectation: "DELETE FROM \"mySchema\".\"myTable\" WHERE \"id\" IN (SELECT \"id\" FROM \"mySchema\".\"myTable\" WHERE \"name\"='foo'';DROP TABLE mySchema.myTable;' LIMIT 10)" expectation: "DELETE FROM \"mySchema\".\"myTable\" WHERE \"id\" IN (SELECT \"id\" FROM \"mySchema\".\"myTable\" WHERE \"name\"='foo'';DROP TABLE mySchema.myTable;' LIMIT 10)"
}, { }, {
arguments: ['myTable', {name: 'foo'}, {limit: null}], arguments: ['myTable', {name: 'foo'}, {limit: null}],
...@@ -795,11 +795,11 @@ if (dialect.match(/^postgres/)) { ...@@ -795,11 +795,11 @@ if (dialect.match(/^postgres/)) {
expectation: "DELETE FROM myTable WHERE id IN (SELECT id FROM myTable WHERE name='foo'';DROP TABLE myTable;' LIMIT 10)", expectation: "DELETE FROM myTable WHERE id IN (SELECT id FROM myTable WHERE name='foo'';DROP TABLE myTable;' LIMIT 10)",
context: {options: {quoteIdentifiers: false}} context: {options: {quoteIdentifiers: false}}
}, { }, {
arguments: [{schema: 'mySchema', tableName: 'myTable'}, {name: 'foo'}], arguments: ['mySchema.myTable', {name: 'foo'}],
expectation: "DELETE FROM mySchema.myTable WHERE id IN (SELECT id FROM mySchema.myTable WHERE name='foo' LIMIT 1)", expectation: "DELETE FROM mySchema.myTable WHERE id IN (SELECT id FROM mySchema.myTable WHERE name='foo' LIMIT 1)",
context: {options: {quoteIdentifiers: false}} context: {options: {quoteIdentifiers: false}}
}, { }, {
arguments: [{schema: 'mySchema', tableName: 'myTable'}, {name: "foo';DROP TABLE mySchema.myTable;"}, {limit: 10}], arguments: ['mySchema.myTable', {name: "foo';DROP TABLE mySchema.myTable;"}, {limit: 10}],
expectation: "DELETE FROM mySchema.myTable WHERE id IN (SELECT id FROM mySchema.myTable WHERE name='foo'';DROP TABLE mySchema.myTable;' LIMIT 10)", expectation: "DELETE FROM mySchema.myTable WHERE id IN (SELECT id FROM mySchema.myTable WHERE name='foo'';DROP TABLE mySchema.myTable;' LIMIT 10)",
context: {options: {quoteIdentifiers: false}} context: {options: {quoteIdentifiers: false}}
}, { }, {
......
...@@ -227,7 +227,7 @@ describe(Support.getTestDialectTeaser("Promise"), function () { ...@@ -227,7 +227,7 @@ describe(Support.getTestDialectTeaser("Promise"), function () {
.then(function() { .then(function() {
return Book return Book
.find({ .find({
where: (dialect === 'postgres' ? '"Books"."id"=' : '`Books`.`id`=') + book.id, where: (dialect === 'postgres' ? '"Book"."id"=' : '`Book`.`id`=') + book.id,
include: [Page] include: [Page]
}) })
.then(function (leBook) { .then(function (leBook) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!