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

Commit c98db629 by Jean-Philippe Monette

Fixing "error: syntax error at or near ")""

When trying to insert values containing the character `)`, the RegEx is not modifying the string properly, throwing this error message: `error: syntax error at or near ")"`.

Here's an example:

Initial value:
`VALUES ( \'Current Generator(s)\',\'CurrentGenerators__c\',NULL,NULL,\'Lead\',\'2014-12-10 22:31:24.076 +00:00\',\'2014-12-10 22:31:24.076 +00:00\');`

Current result:
`SELECT \'Current Generator(s\',\'CurrentGenerators__c\',NULL,NULL,\'Lead\',\'2014-12-10 22:31:24.076 +00:00\',\'2014-12-10 22:31:24.076 +00:00\');`

Expected result:
`SELECT \'Current Generator(s)\',\'CurrentGenerators__c\',NULL,NULL,\'Lead\',\'2014-12-10 22:31:24.076 +00:00\',\'2014-12-10 22:31:24.076 +00:00\';`

This commit is removing the `replace()` method called. After reading the blog post referred, there's no explanation of why this need to be replaced - and it is working fine without it.
1 parent eea1c58a
Showing with 1 additions and 1 deletions
...@@ -355,7 +355,7 @@ module.exports = (function() { ...@@ -355,7 +355,7 @@ module.exports = (function() {
// http://www.maori.geek.nz/post/postgres_upsert_update_or_insert_in_ger_using_knex_js // http://www.maori.geek.nz/post/postgres_upsert_update_or_insert_in_ger_using_knex_js
upsertQuery: function (tableName, insertValues, updateValues, where, rawAttributes, options) { upsertQuery: function (tableName, insertValues, updateValues, where, rawAttributes, options) {
var insert = this.insertQuery(tableName, insertValues, rawAttributes, options).replace(/VALUES \((.*?)\)/, 'SELECT $1'); var insert = this.insertQuery(tableName, insertValues, rawAttributes, options);
var update = this.updateQuery(tableName, updateValues, where, options, rawAttributes); var update = this.updateQuery(tableName, updateValues, where, options, rawAttributes);
// The numbers here are selected to match the number of affected rows returned by MySQL // The numbers here are selected to match the number of affected rows returned by MySQL
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!