Skip to content

Commit 5d048eb

Browse files
committed
Improve create_index
1 parent 49f0f31 commit 5d048eb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/SQL/Translator/Producer/PostgreSQL.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,13 @@ sub alter_create_index {
923923
my ($index, $options) = @_;
924924
my $generator = _generator($options);
925925
my ($idef, $constraints) = create_index($index, $options);
926-
return $index->type eq NORMAL ? $idef
926+
927+
# Just like 90726ffd commit: don't run into output like this:
928+
# ALTER TABLE users ADD ;
929+
# create_index returns one of: index definition or constraint
930+
931+
# So define index or constraint
932+
return $idef ? $idef
927933
: sprintf('ALTER TABLE %s ADD %s',
928934
$generator->quote($index->table->name),
929935
join(q{}, @$constraints)

0 commit comments

Comments
 (0)