From b44e12018b096c3caeeb0ed8e70bdf5133f7c833 Mon Sep 17 00:00:00 2001 From: Julien Enselme Date: Tue, 10 Oct 2023 14:59:12 +0200 Subject: [PATCH 1/4] Prevent invalid SQL detection when keyword is part of something else This could happen for instance when a string contained attachedField: attach was incorrectly detected as the start of some SQL. This resulted in a random word being highlighted and the Python syntax highlighting to be messed up. --- syntaxes/highlight-sql-string.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/highlight-sql-string.tmLanguage.json b/syntaxes/highlight-sql-string.tmLanguage.json index 1b989b8..fed8957 100644 --- a/syntaxes/highlight-sql-string.tmLanguage.json +++ b/syntaxes/highlight-sql-string.tmLanguage.json @@ -6,7 +6,7 @@ "patterns": [ { "name": "meta.embedded.block.sql", - "begin": "\\s*((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace))", + "begin": "\\s*((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace))\\s+", "end": ";|(?=\"\"\"|\"|--|((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace)))", "beginCaptures": { "1": { From e569493b78a969e2af291cfc047e5de8ccbbd0f4 Mon Sep 17 00:00:00 2001 From: Julien Enselme Date: Tue, 10 Oct 2023 15:13:00 +0200 Subject: [PATCH 2/4] Add support for CTEs --- syntaxes/highlight-sql-string.tmLanguage.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntaxes/highlight-sql-string.tmLanguage.json b/syntaxes/highlight-sql-string.tmLanguage.json index fed8957..e78b9f4 100644 --- a/syntaxes/highlight-sql-string.tmLanguage.json +++ b/syntaxes/highlight-sql-string.tmLanguage.json @@ -6,8 +6,8 @@ "patterns": [ { "name": "meta.embedded.block.sql", - "begin": "\\s*((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace))\\s+", - "end": ";|(?=\"\"\"|\"|--|((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace)))", + "begin": "\\s*((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))\\s+", + "end": ";|(?=\"\"\"|\"|--|((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))\\s+)", "beginCaptures": { "1": { "name": "keyword.other.DML.sql" From b8f8a42cc4ca22550ea16710f38f922c933d68bb Mon Sep 17 00:00:00 2001 From: Julien Enselme Date: Tue, 10 Oct 2023 15:30:55 +0200 Subject: [PATCH 3/4] Improve support for simple quotes --- syntaxes/highlight-sql-string.tmLanguage.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntaxes/highlight-sql-string.tmLanguage.json b/syntaxes/highlight-sql-string.tmLanguage.json index e78b9f4..3f1fc33 100644 --- a/syntaxes/highlight-sql-string.tmLanguage.json +++ b/syntaxes/highlight-sql-string.tmLanguage.json @@ -6,8 +6,8 @@ "patterns": [ { "name": "meta.embedded.block.sql", - "begin": "\\s*((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))\\s+", - "end": ";|(?=\"\"\"|\"|--|((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))\\s+)", + "begin": "\\s*((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))", + "end": ";|(?=\"\"\"|\"|'|'''|--|((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))\\s+)", "beginCaptures": { "1": { "name": "keyword.other.DML.sql" From 1bd400cf89907a1b992345ff3f0d0038396cb171 Mon Sep 17 00:00:00 2001 From: Julien Enselme Date: Tue, 10 Oct 2023 15:35:30 +0200 Subject: [PATCH 4/4] fixup! Add support for CTEs --- syntaxes/highlight-sql-string.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/highlight-sql-string.tmLanguage.json b/syntaxes/highlight-sql-string.tmLanguage.json index 3f1fc33..99863d9 100644 --- a/syntaxes/highlight-sql-string.tmLanguage.json +++ b/syntaxes/highlight-sql-string.tmLanguage.json @@ -6,7 +6,7 @@ "patterns": [ { "name": "meta.embedded.block.sql", - "begin": "\\s*((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))", + "begin": "\\s*((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))\\s+", "end": ";|(?=\"\"\"|\"|'|'''|--|((?i)(explain|alter|analyze|attach|begin|commit|create|delete|detach|drop|insert|pragma|reindex|release|rollback|savepoint|select|update|vacuum|replace|with))\\s+)", "beginCaptures": { "1": {