Skip to content

Commit

Permalink
schemawatch: Ignore hidden Oracle Database columns
Browse files Browse the repository at this point in the history
This change updates the column inspection query to also consider the
HIDDEN_COLUMN value when deciding which columns to ignore.
  • Loading branch information
bobvawter committed Sep 19, 2024
1 parent 88bbb21 commit b7f9e98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/target/schemawatch/coldata.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ WITH atc AS (
ELSE DATA_TYPE
END DATA_TYPE,
DATA_DEFAULT,
HIDDEN_COLUMN,
VIRTUAL_COLUMN FROM ALL_TAB_COLS
),
pk_cols AS (SELECT OWNER, TABLE_NAME, CONSTRAINT_NAME FROM ALL_CONSTRAINTS WHERE CONSTRAINT_TYPE='P'),
Expand All @@ -254,7 +255,8 @@ SELECT /*+ gather_plan_statistics */
COALESCE(IS_PK, 'f'),
atc.DATA_TYPE,
atc.DATA_DEFAULT,
CASE WHEN atc.VIRTUAL_COLUMN = 'YES' THEN 't' ELSE 'f' END
CASE WHEN (atc.HIDDEN_COLUMN = 'YES' OR atc.VIRTUAL_COLUMN = 'YES')
THEN 't' ELSE 'f' END
FROM atc
LEFT JOIN pk_cols USING (OWNER, TABLE_NAME)
LEFT JOIN acc USING (OWNER, TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME)
Expand Down
12 changes: 12 additions & 0 deletions internal/target/schemawatch/coldata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@ func TestGetColumns(t *testing.T) {
"d", "VARCHAR2(1 CHAR)",
),
},
// Verify that hidden columns are ignored.
{
products: []types.Product{types.ProductOracle},
tableSchema: "a INT PRIMARY KEY, b VARCHAR2(1 CHAR) DEFAULT 'n' NULL, c INT INVISIBLE",
primaryKeys: []string{"a"},
dataCols: []string{"b", "ignored_c"},
types: ident.MapOf[string](
"a", "NUMBER",
"b", "VARCHAR2(1 CHAR)",
"c", "NUMBER",
),
},
// Check default value extraction
{
products: []types.Product{types.ProductCockroachDB, types.ProductMariaDB,
Expand Down

0 comments on commit b7f9e98

Please sign in to comment.