package SQL::Translator::Parser::Oracle;
# -------------------------------------------------------------------
-# $Id: Oracle.pm,v 1.23 2006-05-03 21:46:06 duality72 Exp $
+# $Id: Oracle.pm,v 1.24 2006-05-05 16:42:17 duality72 Exp $
# -------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use strict;
use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.23 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.24 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
fields => $item[3],
reference_table => $item[6],
reference_fields => $item[7][0],
- match_type => $item[8][0],
- on_delete => $item[9][0],
- on_update => $item[10][0],
+# match_type => $item[8][0],
+ on_delete => $item[8][0],
+# on_update => $item[9][0],
}
}
on_delete : /on delete/i WORD(s)
- { $item[2] }
+ { join(' ', @{$item[2]}) }
UNIQUE : /unique/i { $return = 1 }
use SQL::Translator::Schema::Constants;
use Test::SQL::Translator qw(maybe_plan);
-maybe_plan(79, 'SQL::Translator::Parser::Oracle');
+maybe_plan(85, 'SQL::Translator::Parser::Oracle');
SQL::Translator::Parser::Oracle->import('parse');
my $t = SQL::Translator->new( trace => 0 );
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 @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"' );