From 822593e545a601ae9fc665667d2a6eb75a36f987 Mon Sep 17 00:00:00 2001 From: Clayton Grassick Date: Wed, 21 Jul 2021 11:15:49 -0500 Subject: [PATCH] Compile --- lib/SqlFragment.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SqlFragment.js b/lib/SqlFragment.js index 9179f6a09..174f783d4 100644 --- a/lib/SqlFragment.js +++ b/lib/SqlFragment.js @@ -63,7 +63,8 @@ class SqlFragment { let n = 0; // All the question marks not followed by | or & // ?| and ?& are jsonb operators (so is ?, but it can be replaced by one of the others) - const sql = this.sql.replace(/\?(?!\||&)/g, (str) => { + // This complex expression is to not match 'xyz?'. See https://stackoverflow.com/questions/6462578/regex-to-match-all-instances-not-inside-quotes + const sql = this.sql.replace(/\?(?!\||&)(?=([^']*'[^']*')*[^']*$)/g, (str) => { // Insert nth parameter // Check type const param = this.params[n];