From 2124b77a2a7246699b58a1677f0afcc58160318c Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sat, 18 Jan 2025 14:34:42 +0200 Subject: [PATCH] fixed multiple comment blocks parsing --- core/view.go | 2 +- core/view_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/view.go b/core/view.go index aee9cd81..d7db6257 100644 --- a/core/view.go +++ b/core/view.go @@ -440,7 +440,7 @@ func getQueryTableInfo(app App, selectQuery string) ([]*TableInfoRow, error) { var ( joinReplaceRegex = regexp.MustCompile(`(?im)\s+(full\s+outer\s+join|left\s+outer\s+join|right\s+outer\s+join|full\s+join|cross\s+join|inner\s+join|outer\s+join|left\s+join|right\s+join|join)\s+?`) discardReplaceRegex = regexp.MustCompile(`(?im)\s+(where|group\s+by|having|order|limit|with)\s+?`) - commentsReplaceRegex = regexp.MustCompile(`(?m)(\/\*[\s\S]+\*\/)|(--.+$)`) + commentsReplaceRegex = regexp.MustCompile(`(?m)(\/\*[\s\S]*?\*\/)|(--.+$)`) ) type identifier struct { diff --git a/core/view_test.go b/core/view_test.go index 801ca852..37eb2fcd 100644 --- a/core/view_test.go +++ b/core/view_test.go @@ -249,8 +249,8 @@ func TestCreateViewFields(t *testing.T) { demo1.id, demo1.text, /* multi - line comment */ - demo1.url, demo1.created, demo2.updated from demo1 + * line comment block */ + demo1.url, demo1.created, demo1.updated from/* inline comment block with no spaces between the identifiers */demo1 -- comment before join join demo2 ON ( -- comment inside join