Skip to content

Commit

Permalink
More cases and a TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanslade authored and andrew-farries committed Dec 20, 2024
1 parent 2673a27 commit 6e6e573
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/sql2pgroll/create_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func canConvertCreateIndexStmt(stmt *pgq.IndexStmt) bool {
if param.GetIndexElem().GetNullsOrdering() != pgq.SortByNulls_SORTBY_NULLS_DEFAULT {
return false
}
if param.GetIndexElem().GetOpclass() != nil || param.GetIndexElem().GetOpclassopts() != nil {
return false
}
}
if stmt.GetTableSpace() != "" {
return false
Expand Down
9 changes: 5 additions & 4 deletions pkg/sql2pgroll/create_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ func TestConvertCreateIndexStatements(t *testing.T) {
sql: "CREATE INDEX idx_name ON foo (bar ASC)",
expectedOp: expect.CreateIndexOp1,
},
{
sql: "CREATE INDEX idx_name ON foo (bar NULLS)",
expectedOp: expect.CreateIndexOp1,
},
{
sql: "CREATE INDEX idx_name ON foo USING btree (bar)",
expectedOp: expect.CreateIndexOp1,
Expand Down Expand Up @@ -137,6 +133,11 @@ func TestUnconvertableCreateIndexStatements(t *testing.T) {
"CREATE INDEX idx_name ON foo (bar NULLS FIRST)",
"CREATE INDEX idx_name ON foo (bar NULLS LAST)",
"CREATE INDEX idx_name ON foo (bar) INCLUDE (baz)",
"CREATE INDEX idx_name ON foo (bar opclass (test = test))",
"CREATE INDEX idx_name ON foo (bar NULLS)",

// TODO: Can't figure out how to detect this case
//"CREATE INDEX idx_name ON ONLY foo (bar)",
}

for _, sql := range tests {
Expand Down

0 comments on commit 6e6e573

Please sign in to comment.