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

Commit 57dec764 by Joshua Perry

Error on empty result from table definition queries

1 parent 0121225f
Showing with 10 additions and 1 deletions
......@@ -328,7 +328,16 @@ module.exports = (function() {
sql = 'DESCRIBE ' + table + ';'
}
return this.sequelize.query(sql, null, { raw: true })
this.sequelize.query(sql, null, { raw: true }).then(function(data) {
// If no data is returned from the query, then the table name may be wrong.
// Query generators that use information_schema for retrieving table info will just return an empty result set,
// it will not throw an error like built-ins do (e.g. DESCRIBE on MySql).
if(Utils._.isEmpty(data)) {
return Promise.reject('No description found for "' + table + '" table. Check the table name and schema; remember, they _are_ case sensitive.')
} else {
return Promise.resolve(data)
}
})
}
QueryInterface.prototype.addColumn = function(tableName, attributeName, dataTypeOrOptions) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!