Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(parser): support PostgreSQL COMMENT statement (#2836)
rebelice83d4dcf2c21e
diff --git a/plugin/parser/ast/comment_stmt.go b/plugin/parser/ast/comment_stmt.gonew file mode 100644index 0000000000..9309d87f9b--- /dev/null+++ b/plugin/parser/ast/comment_stmt.go@@ -0,0 +1,8 @@+package ast++// CommentStmt is the struct for comment statement.+type CommentStmt struct {+ node++ Comment string+}diff --git a/plugin/parser/engine/pg/convert.go b/plugin/parser/engine/pg/convert.goindex 7df690a39f..5152b8fc17 100644--- a/plugin/parser/engine/pg/convert.go+++ b/plugin/parser/engine/pg/convert.go@@ -366,6 +366,12 @@ func convert(node *pgquery.Node, statement parser.SingleSQL) (res ast.Node, err}return ©Stmt, nil+ case *pgquery.Node_CommentStmt:+ commentStmt := ast.CommentStmt{+ Comment: in.CommentStmt.Comment,+ }++ return &commentStmt, nildefault:return &ast.UnconvertedStmt{}, nil}diff --git a/plugin/parser/engine/pg/convert_test.go b/plugin/parser/engine/pg/convert_test.goindex 552b123e67..b7f442520c 100644--- a/plugin/parser/engine/pg/convert_test.go+++ b/plugin/parser/engine/pg/convert_test.go@@ -1733,3 +1733,22 @@ func TestUnconvertStmt(t *testing.T) {runTests(t, tests)}++func TestCommentStmt(t *testing.T) {+ tests := []testData{+ {+ stmt: "COMMENT ON TABLE tech_book IS 'This is a comment.'",+ want: []ast.Node{&ast.CommentStmt{+ Comment: "This is a comment.",+ }},+ statementList: []parser.SingleSQL{+ {+ Text: "COMMENT ON TABLE tech_book IS 'This is a comment.'",+ LastLine: 1,+ },+ },+ },+ }++ runTests(t, tests)+}