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

Commit 9b73d157 by contra Committed by Jan Aagaard Meier

add a more informative error message (#6915)

right now this is basically impossible to track down the root. this PR adds a more informative error message so you actually know what caused the error.

Before:

```
TypeError: sql.replace is not a function
        at Object.format (/Users/contra/Projects/staeco/node_modules/sequelize/lib/sql-string.js:87:14)
        at Object.format (/Users/contra/Projects/staeco/node_modules/sequelize/lib/utils.js:119:20)
        at Object.getWhereConditions (/Users/contra/Projects/staeco/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2303:24)
```

After:

```js
Error: Invalid SQL string provided: ST_Intersects(123)
        at Object.format (/Users/contra/Projects/staeco/node_modules/sequelize/lib/sql-string.js:87:14)
        at Object.format (/Users/contra/Projects/staeco/node_modules/sequelize/lib/utils.js:119:20)
        at Object.getWhereConditions (/Users/contra/Projects/staeco/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2303:24)
```
1 parent 86ea4beb
Showing with 3 additions and 0 deletions
......@@ -83,6 +83,9 @@ exports.escape = escape;
function format(sql, values, timeZone, dialect) {
values = [].concat(values);
if (typeof sql !== 'string') {
throw new Error('Invalid SQL string provided: ' + sql);
}
return sql.replace(/\?/g, match => {
if (!values.length) {
return match;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!