Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: set line for inline constraint to the column line (#2322)
rebelice29301786f9d5
diff --git a/plugin/parser/engine/pg/convert_test.go b/plugin/parser/engine/pg/convert_test.goindex 836fe82181..6e3020ad7e 100644--- a/plugin/parser/engine/pg/convert_test.go+++ b/plugin/parser/engine/pg/convert_test.go@@ -30,6 +30,9 @@ func runTests(t *testing.T, tests []testData) {case *ast.CreateTableStmt:for j, col := range n.ColumnList {col.SetLine(test.columnLine[i][j])+ for _, inlineCons := range col.ConstraintList {+ inlineCons.SetLine(col.Line())+ }}for j, cons := range n.ConstraintList {cons.SetLine(test.constraintLine[i][j])diff --git a/plugin/parser/set_line_for_create_table_test.go b/plugin/parser/set_line_for_create_table_test.goindex 59531211b1..12903420da 100644--- a/plugin/parser/set_line_for_create_table_test.go+++ b/plugin/parser/set_line_for_create_table_test.go@@ -73,6 +73,9 @@ func TestPGCreateTableSetLine(t *testing.T) {require.Equal(t, len(test.constraintLineList), len(node.ConstraintList))for i, col := range node.ColumnList {require.Equal(t, col.Line(), test.columnLineList[i], i)+ for _, inlineCons := range col.ConstraintList {+ require.Equal(t, test.columnLineList[i], inlineCons.Line())+ }}for i, cons := range node.ConstraintList {require.Equal(t, cons.Line(), test.constraintLineList[i], i)diff --git a/plugin/parser/tokenizer.go b/plugin/parser/tokenizer.goindex f2903f8394..15162411a4 100644--- a/plugin/parser/tokenizer.go+++ b/plugin/parser/tokenizer.go@@ -47,6 +47,9 @@ func (t *tokenizer) setLineForCreateTableStmt(node *ast.CreateTableStmt) error {// If it breaks our assumption, we set the line for columns and table constraints to the first line of the CREATE TABLE statement.for _, col := range node.ColumnList {col.SetLine(node.Line())+ for _, inlineCons := range col.ConstraintList {+ inlineCons.SetLine(node.Line())+ }}for _, cons := range node.ConstraintList {cons.SetLine(node.Line())@@ -81,6 +84,9 @@ func (t *tokenizer) setLineForCreateTableStmt(node *ast.CreateTableStmt) error {if columnPos < len(node.ColumnList) &&strings.Contains(def, strings.ToLower(node.ColumnList[columnPos].ColumnName)) {node.ColumnList[columnPos].SetLine(t.startLine + node.Line() - 1)+ for _, inlineConstraint := range node.ColumnList[columnPos].ConstraintList {+ inlineConstraint.SetLine(node.ColumnList[columnPos].Line())+ }} else if constraintPos < len(node.ConstraintList) &&matchTableConstraint(def, node.ConstraintList[constraintPos]) {node.ConstraintList[constraintPos].SetLine(t.startLine + node.Line() - 1)@@ -93,6 +99,9 @@ func (t *tokenizer) setLineForCreateTableStmt(node *ast.CreateTableStmt) error {if columnPos < len(node.ColumnList) &&strings.Contains(def, strings.ToLower(node.ColumnList[columnPos].ColumnName)) {node.ColumnList[columnPos].SetLine(t.startLine + node.Line() - 1)+ for _, inlineConstraint := range node.ColumnList[columnPos].ConstraintList {+ inlineConstraint.SetLine(node.ColumnList[columnPos].Line())+ }columnPos++} else if constraintPos < len(node.ConstraintList) &&matchTableConstraint(def, node.ConstraintList[constraintPos]) {