use SQL::Translator::Schema::Constants;
use Test::SQL::Translator qw(maybe_plan);
-maybe_plan(76, 'SQL::Translator::Parser::Oracle');
+maybe_plan(89, 'SQL::Translator::Parser::Oracle');
SQL::Translator::Parser::Oracle->import('parse');
my $t = SQL::Translator->new( trace => 0 );
CREATE UNIQUE INDEX qtl_accession ON qtl ( qtl_accession_id );
CREATE UNIQUE INDEX qtl_accession_upper ON qtl ( UPPER(qtl_accession_id) );
+ CREATE INDEX qtl_index ON qtl ( qtl_accession_id );
CREATE TABLE qtl_trait_synonym
(
trait_synonym VARCHAR2(200) NOT NULL,
qtl_trait_id NUMBER(11) NOT NULL,
UNIQUE( qtl_trait_id, trait_synonym ),
- FOREIGN KEY ( qtl_trait_id ) REFERENCES qtl_trait
+ FOREIGN KEY ( qtl_trait_id ) REFERENCES qtl_trait ON DELETE SET NULL
);
];
my @t3_constraints = $t3->get_constraints;
is( scalar @t3_constraints, 4, '4 constraints on table' );
+my $t3_c4 = $t3_constraints[3];
+is( $t3_c4->type, UNIQUE, 'Fourth constraint is unique' );
+is( $t3_c4->name, 'qtl_accession_upper', 'Name = "qtl_accession_upper"' );
+is( join(',', $t3_c4->fields), 'UPPER(qtl_accession_id)', 'Fields = "UPPER(qtl_accession_id)"' );
is( $t3->comments, 'qtl table comment', 'Comment "qtl table comment" exists' );
is( $t3_f2->comments, 'accession comment',
'Comment "accession comment" exists' );
+my @t3_indices = $t3->get_indices;
+is( scalar @t3_indices, 1, '1 index on table' );
+
+my $t3_i1 = shift @t3_indices;
+is( $t3_i1->type, 'NORMAL', 'First index is normal' );
+is( $t3_i1->name, 'qtl_index', 'Name is "qtl_index"' );
+is( join(',', $t3_i1->fields), 'qtl_accession_id', 'Fields = "qtl_accession_id"' );
+
#
# qtl_trait_synonym
#
my @t4_constraints = $t4->get_constraints;
is( scalar @t4_constraints, 3, '3 constraints on table' );
+my $t4_c3 = $t4_constraints[2];
+is( $t4_c3->type, FOREIGN_KEY, 'Third constraint is FK' );
+is( $t4_c3->name, '', 'No name' );
+is( join(',', $t4_c3->fields), 'qtl_trait_id',
+ 'Fields = "qtl_trait_id"' );
+is( $t4_c3->reference_table, 'qtl_trait',
+ 'Reference table = "qtl_trait"' );
+is( join(',', $t4_c3->reference_fields), 'qtl_trait_id',
+ 'Reference fields = "qtl_trait_id"' );
+is( $t4_c3->on_delete, 'SET NULL',
+ 'on_delete = "SET NULL"' );