Skip to content

Commit

Permalink
Use raw SQL for NULLS NOT DISTINCT indexes
Browse files Browse the repository at this point in the history
This option is not representable by the `pgroll` operation.
  • Loading branch information
andrew-farries committed Dec 20, 2024
1 parent edd1cd9 commit e258656
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sql2pgroll/create_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func canConvertCreateIndexStmt(stmt *pgq.IndexStmt) bool {
if !stmt.GetRelation().GetInh() {
return false
}
// Indexes with NULLS NOT DISTINCT are not supported
if stmt.GetNullsNotDistinct() {
return false
}

for _, param := range stmt.GetIndexParams() {
if param.GetIndexElem().GetCollation() != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql2pgroll/create_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ func TestUnconvertableCreateIndexStatements(t *testing.T) {
"CREATE INDEX idx_name ON foo (bar opclass)",
// Indexes created with ONLY are not supported
"CREATE INDEX idx_name ON ONLY foo (bar)",
// Indexes with NULLS NOT DISTINCT are not supported
"CREATE INDEX idx_foo ON foo(a) NULLS NOT DISTINCT",
}

for _, sql := range tests {
Expand Down

0 comments on commit e258656

Please sign in to comment.