* Fix forgotten quoting in the MySQL DROP TABLE diff producer (GH#50)
* Fix Pg grammar parsing of UUID, time, timetz columns (RT#100196, GH#52)
* Add support for USING and WHERE on indexes in PostgreSQL producer
- (RT#63814, GH#52)
+ and parser (RT#63814, GH#52)
* Improve add_trigger consistency between producers (GH#48)
* Declare dependencies in deterministic order (RT#102859)
* Multiple speedups of naive internal debugging mechanism (GH#54)
supertype => $item{'unique'}[0] ? 'constraint' : 'index',
type => $item{'unique'}[0] ? 'unique' : 'normal',
fields => $item[9],
- method => $item{'using_method'}[0],
+ method => $item{'using_method(?)'}[0],
+ where => $item{'where_predicate(?)'}[0],
}
;
}
}
for my $idata ( @{ $tdata->{'indices'} || [] } ) {
+ my @options = ();
+ push @options, { using => $idata->{'method'} } if $idata->{method};
+ push @options, { where => $idata->{'where'} } if $idata->{where};
my $index = $table->add_index(
- name => $idata->{'name'},
- type => uc $idata->{'type'},
- fields => $idata->{'fields'},
+ name => $idata->{'name'},
+ type => uc $idata->{'type'},
+ fields => $idata->{'fields'},
+ options => \@options
) or die $table->error . ' ' . $table->name;
}
FOR EACH ROW
EXECUTE PROCEDURE foo();
+ CREATE INDEX test_index1 ON t_test1 (f_varchar);
+ CREATE INDEX test_index2 ON t_test1 USING hash (f_char, f_bool);
+ CREATE INDEX test_index3 ON t_test1 USING hash (f_bigint, f_tz) WHERE f_bigint = '1' AND f_tz IS NULL;
+
alter table t_test1 add f_fk2 integer;
alter table only t_test1 add constraint c_u1 unique (f_varchar);
is( $trigger->scope, 'row', "Correct scope for trigger");
is( $trigger->action, 'EXECUTE PROCEDURE foo()', "Correct action for trigger");
+# test index
+my @indices = $t1->get_indices;
+is(scalar @indices, 3, 'got three indexes');
+
+my $t1_i1 = $indices[0];
+is( $t1_i1->name, 'test_index1', 'First index is "test_index1"' );
+is( join(',', $t1_i1->fields), 'f_varchar', 'Index is on field "f_varchar"' );
+is_deeply( [ $t1_i1->options ], [], 'Index is has no options' );
+
+my $t1_i2 = $indices[1];
+is( $t1_i2->name, 'test_index2', 'Second index is "test_index2"' );
+is( join(',', $t1_i2->fields), 'f_char,f_bool', 'Index is on fields "f_char, f_bool"' );
+is_deeply( [ $t1_i2->options ], [ { using => 'hash' } ], 'Index is using hash method' );
+
+my $t1_i3 = $indices[2];
+is( $t1_i3->name, 'test_index3', 'Third index is "test_index3"' );
+is( join(',', $t1_i3->fields), 'f_bigint,f_tz', 'Index is on fields "f_bigint, f_tz"' );
+is_deeply(
+ [ $t1_i3->options ],
+ [ { using => 'hash' }, { where => "f_bigint = '1' AND f_tz IS NULL" } ],
+ 'Index is using hash method and has predicate right'
+);
+
done_testing;