Skip to content

Commit 4e43d99

Browse files
tianzhouclaude
andcommitted
fix: address review feedback - signature stripping, TABLE/VIEW separation, view column privileges
- Strip function/procedure argument lists before matching ignore patterns (fixes exact-name patterns like "dblink_connect_u" vs "dblink_connect_u(text)") - Separate TABLE and VIEW into distinct switch cases to prevent cross-contamination - Also filter column privileges on ignored views, not just tables - Fix cleanup comment in test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 486335f commit 4e43d99

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

cmd/ignore_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ GRANT SELECT ON users TO app_user;
13211321
}
13221322
})
13231323

1324-
// Clean up roles from embedded PG
1324+
// Clean up roles from sharedEmbeddedPG (plan subtest may create roles there)
13251325
cleanupStatements := []string{
13261326
"REASSIGN OWNED BY app_user TO testuser",
13271327
"DROP OWNED BY app_user",

ir/ignore.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import (
55
"strings"
66
)
77

8+
// stripFunctionArgs removes the argument list from a function/procedure signature.
9+
// e.g. "dblink_connect_u(text, text)" -> "dblink_connect_u"
10+
func stripFunctionArgs(name string) string {
11+
if idx := strings.Index(name, "("); idx != -1 {
12+
return name[:idx]
13+
}
14+
return name
15+
}
16+
817
// IgnoreConfig represents the configuration for ignoring database objects
918
type IgnoreConfig struct {
1019
Tables []string `toml:"tables,omitempty"`
@@ -73,13 +82,14 @@ func (c *IgnoreConfig) ShouldIgnorePrivilegeByObjectType(objectName string, obje
7382
return false
7483
}
7584
switch objectType {
76-
case "TABLE", "VIEW":
77-
// Views use table-level privileges in PostgreSQL
78-
return c.shouldIgnore(objectName, c.Tables) || c.shouldIgnore(objectName, c.Views)
85+
case "TABLE":
86+
return c.shouldIgnore(objectName, c.Tables)
87+
case "VIEW":
88+
return c.shouldIgnore(objectName, c.Views)
7989
case "FUNCTION":
80-
return c.shouldIgnore(objectName, c.Functions)
90+
return c.shouldIgnore(stripFunctionArgs(objectName), c.Functions)
8191
case "PROCEDURE":
82-
return c.shouldIgnore(objectName, c.Procedures)
92+
return c.shouldIgnore(stripFunctionArgs(objectName), c.Procedures)
8393
case "SEQUENCE":
8494
return c.shouldIgnore(objectName, c.Sequences)
8595
case "TYPE":

ir/inspector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,8 +2480,8 @@ func (i *Inspector) buildColumnPrivileges(ctx context.Context, schema *IR, targe
24802480
continue
24812481
}
24822482

2483-
// Skip column privileges for ignored tables
2484-
if i.ignoreConfig != nil && i.ignoreConfig.ShouldIgnoreTable(tableName) {
2483+
// Skip column privileges for ignored tables/views
2484+
if i.ignoreConfig != nil && (i.ignoreConfig.ShouldIgnoreTable(tableName) || i.ignoreConfig.ShouldIgnoreView(tableName)) {
24852485
continue
24862486
}
24872487

0 commit comments

Comments
 (0)