From 369e144c65244ede84cfcc3ac24b2b3c6768ef2a Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 16 Mar 2022 09:57:56 +0100 Subject: [PATCH 1/7] fix keep preselect if not insert --- lib/myutils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/myutils.js b/lib/myutils.js index 457cc051..33104b91 100644 --- a/lib/myutils.js +++ b/lib/myutils.js @@ -322,7 +322,7 @@ function ruleWithContext(rule) { // PreContext const preSelectMatch = ruleText.match(/.+?(?=\bselect )/i); const preInsertMatch = preSelectMatch ? preSelectMatch[0].match(/.+?(?=\insert )/i) : null; - const insertionPreContext = preInsertMatch ? preInsertMatch[0] : ''; + const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch[0]; // PostContext const InsertMatch = ruleText.match(/\binsert .*/i); var insertionPostContext; @@ -336,13 +336,13 @@ function ruleWithContext(rule) { // Context select YYY return util.format('%s context %s %s', insertionPreContext, contextName(rule), insertionPostContext).trim(); } - +n; function ruleWithContextTimedRule(rule) { const ruleText = removeCRLFchars(rule.text); // PreContext const preSelectMatch = ruleText.match(/.+?(?=\bselect )/i); const preInsertMatch = preSelectMatch ? preSelectMatch[0].match(/.+?(?=\insert )/i) : null; - const insertionPreContext = preInsertMatch ? preInsertMatch[0] : ''; + const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch[0]; // PostContext const InsertMatch = ruleText.match(/\binsert .*/i); var insertionPostContext; From 30f7271a511a8c1db2fa016718e4aa2ecc5f2ada Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 16 Mar 2022 10:05:31 +0100 Subject: [PATCH 2/7] fix typo --- lib/myutils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/myutils.js b/lib/myutils.js index 33104b91..61715440 100644 --- a/lib/myutils.js +++ b/lib/myutils.js @@ -336,7 +336,7 @@ function ruleWithContext(rule) { // Context select YYY return util.format('%s context %s %s', insertionPreContext, contextName(rule), insertionPostContext).trim(); } -n; + function ruleWithContextTimedRule(rule) { const ruleText = removeCRLFchars(rule.text); // PreContext From 6e032d84c72325ca0e5c84f39900045d392d4def Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 16 Mar 2022 10:11:42 +0100 Subject: [PATCH 3/7] check preInsertMatch --- lib/myutils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/myutils.js b/lib/myutils.js index 61715440..de5a366b 100644 --- a/lib/myutils.js +++ b/lib/myutils.js @@ -322,7 +322,7 @@ function ruleWithContext(rule) { // PreContext const preSelectMatch = ruleText.match(/.+?(?=\bselect )/i); const preInsertMatch = preSelectMatch ? preSelectMatch[0].match(/.+?(?=\insert )/i) : null; - const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch[0]; + const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch ? preSelectMatch[0] : null; // PostContext const InsertMatch = ruleText.match(/\binsert .*/i); var insertionPostContext; From 8b0804c79df62513b46b348880458e35e3837dc8 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 16 Mar 2022 10:16:03 +0100 Subject: [PATCH 4/7] fix in ruleWithContextTimedRule --- lib/myutils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/myutils.js b/lib/myutils.js index de5a366b..20c2a491 100644 --- a/lib/myutils.js +++ b/lib/myutils.js @@ -322,7 +322,7 @@ function ruleWithContext(rule) { // PreContext const preSelectMatch = ruleText.match(/.+?(?=\bselect )/i); const preInsertMatch = preSelectMatch ? preSelectMatch[0].match(/.+?(?=\insert )/i) : null; - const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch ? preSelectMatch[0] : null; + const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch ? preSelectMatch[0] : ''; // PostContext const InsertMatch = ruleText.match(/\binsert .*/i); var insertionPostContext; @@ -342,7 +342,7 @@ function ruleWithContextTimedRule(rule) { // PreContext const preSelectMatch = ruleText.match(/.+?(?=\bselect )/i); const preInsertMatch = preSelectMatch ? preSelectMatch[0].match(/.+?(?=\insert )/i) : null; - const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch[0]; + const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch ? preSelectMatch[0] : ''; // PostContext const InsertMatch = ruleText.match(/\binsert .*/i); var insertionPostContext; From 7edf5126317a948b65018d7374717f5f2886506d Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 16 Mar 2022 10:23:16 +0100 Subject: [PATCH 5/7] refactor --- lib/myutils.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/myutils.js b/lib/myutils.js index 20c2a491..289de6cf 100644 --- a/lib/myutils.js +++ b/lib/myutils.js @@ -321,8 +321,15 @@ function ruleWithContext(rule) { const ruleText = removeCRLFchars(rule.text); // PreContext const preSelectMatch = ruleText.match(/.+?(?=\bselect )/i); - const preInsertMatch = preSelectMatch ? preSelectMatch[0].match(/.+?(?=\insert )/i) : null; - const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch ? preSelectMatch[0] : ''; + var preInsertMatch; + var insertionPreContext; + if (preSelectMatch) { + preInsertMatch = preSelectMatch[0].match(/.+?(?=\insert )/i); + insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch[0]; + } else { + preInsertMatch = null; + insertionPreContext = ''; + } // PostContext const InsertMatch = ruleText.match(/\binsert .*/i); var insertionPostContext; @@ -341,8 +348,15 @@ function ruleWithContextTimedRule(rule) { const ruleText = removeCRLFchars(rule.text); // PreContext const preSelectMatch = ruleText.match(/.+?(?=\bselect )/i); - const preInsertMatch = preSelectMatch ? preSelectMatch[0].match(/.+?(?=\insert )/i) : null; - const insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch ? preSelectMatch[0] : ''; + var preInsertMatch; + var insertionPreContext; + if (preSelectMatch) { + preInsertMatch = preSelectMatch[0].match(/.+?(?=\insert )/i); + insertionPreContext = preInsertMatch ? preInsertMatch[0] : preSelectMatch[0]; + } else { + preInsertMatch = null; + insertionPreContext = ''; + } // PostContext const InsertMatch = ruleText.match(/\binsert .*/i); var insertionPostContext; From 84184cd774819282ef92d47b7e9490070eb8effd Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 16 Mar 2022 10:37:20 +0100 Subject: [PATCH 6/7] Update CHANGES_NEXT_RELEASE --- CHANGES_NEXT_RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index e69de29b..a837741b 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -0,0 +1 @@ +- Hotfix: fix preselect in ruleWithContext (#630) From c36b2f0324a0972685a730f55f6adfa057d567a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Wed, 16 Mar 2022 10:42:30 +0100 Subject: [PATCH 7/7] Update CHANGES_NEXT_RELEASE --- CHANGES_NEXT_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index a837741b..c1f9ff1c 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1 @@ -- Hotfix: fix preselect in ruleWithContext (#630) +- Fix: preselect in ruleWithContext (#630)