Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: fix validateSQL to support "SELECT* FROM ..." (#6120)

rebelice6a04403d7e1b
diff --git a/backend/plugin/parser/sql/validate_sql_for_editor.go b/backend/plugin/parser/sql/validate_sql_for_editor.go
index 54e4b50ce0..eaaa8b6ea0 100644
--- a/backend/plugin/parser/sql/validate_sql_for_editor.go
+++ b/backend/plugin/parser/sql/validate_sql_for_editor.go
@@ -76,6 +76,10 @@ func postgresValidateSQLForEditor(statement string) bool {
return true
}
+ if isSelect, _ := regexp.MatchString(`^SELECT\*\s+?`, formattedStr); isSelect {
+ return true
+ }
+
if isExplain, _ := regexp.MatchString(`^EXPLAIN\s+?`, formattedStr); isExplain {
if isExplainAnalyze, _ := regexp.MatchString(`^EXPLAIN\s+ANALYZE\s+?`, formattedStr); isExplainAnalyze {
return false
@@ -133,6 +137,10 @@ func checkStatementWithoutQuotedTextAndComment(statement string) bool {
return true
}
+ if isSelect, _ := regexp.MatchString(`^SELECT\*\s+?`, formattedStr); isSelect {
+ return true
+ }
+
if isExplain, _ := regexp.MatchString(`^EXPLAIN\s+?`, formattedStr); isExplain {
if isExplainAnalyze, _ := regexp.MatchString(`^EXPLAIN\s+ANALYZE\s+?`, formattedStr); isExplainAnalyze {
return false
diff --git a/backend/plugin/parser/sql/validate_sql_for_editor_test.go b/backend/plugin/parser/sql/validate_sql_for_editor_test.go
index 7079b0095c..5e8161aa86 100644
--- a/backend/plugin/parser/sql/validate_sql_for_editor_test.go
+++ b/backend/plugin/parser/sql/validate_sql_for_editor_test.go
@@ -15,6 +15,10 @@ type testData struct {
func TestValidateSQLForPG(t *testing.T) {
tests := []testData{
+ {
+ sql: `select* from t`,
+ ans: true,
+ },
{
sql: `explain select * from t;`,
ans: true,
@@ -85,6 +89,10 @@ func TestValidateSQLForPG(t *testing.T) {
func TestValidateSQLForMySQL(t *testing.T) {
tests := []testData{
+ {
+ sql: `select* from t`,
+ ans: true,
+ },
{
sql: `explain select * from t;`,
ans: true,
@@ -149,6 +157,10 @@ func TestValidateSQLForMySQL(t *testing.T) {
func TestValidateSQLForStandard(t *testing.T) {
tests := []testData{
+ {
+ sql: `select* from t`,
+ ans: true,
+ },
{
sql: `explain select * from t;`,
ans: true,