X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FOracle.pm;h=ddb6b3f3471cae9a24f3279c8fd08997534b7f0e;hb=7d8f0a61b9fbd54e85625c0f9857fc000ae11bfd;hp=9703f8b9f11b5a6264c71fb3b2811f1aaad148d0;hpb=60979a72c993943ff211c8ad0883f48bd1d63801;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/Oracle.pm b/lib/SQL/Translator/Parser/Oracle.pm index 9703f8b..ddb6b3f 100644 --- a/lib/SQL/Translator/Parser/Oracle.pm +++ b/lib/SQL/Translator/Parser/Oracle.pm @@ -1,9 +1,7 @@ package SQL::Translator::Parser::Oracle; # ------------------------------------------------------------------- -# $Id: Oracle.pm,v 1.29 2007-03-19 22:32:31 duality72 Exp $ -# ------------------------------------------------------------------- -# Copyright (C) 2002-4 SQLFairy Authors +# Copyright (C) 2002-2009 SQLFairy Authors # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -97,7 +95,7 @@ was altered to better handle the syntax created by DDL::Oracle. use strict; use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.29 $ =~ /(\d+)\.(\d+)/; +$VERSION = '1.59'; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -274,8 +272,8 @@ table_name : NAME '.' NAME | NAME { $item[1] } -create_definition : field - | table_constraint +create_definition : table_constraint + | field | table_comment : comment @@ -395,8 +393,8 @@ column_constraint : constraint_name(?) column_constraint_type constraint_state(s name => $item{'constraint_name(?)'}[0] || '', type => $type, expression => $type eq 'check' ? $expression : '', - deferrable => $item{'deferrable'}, - deferred => $item{'deferred'}, + deferrable => $desc->{'deferrable'}, + deferred => $desc->{'deferred'}, reference_table => $desc->{'reference_table'}, reference_fields => $desc->{'reference_fields'}, # match_type => $desc->{'match_type'}, @@ -411,8 +409,13 @@ column_constraint_type : /not\s+null/i { $return = { type => 'not_null' } } { $return = { type => 'unique' } } | /primary\s+key/i { $return = { type => 'primary_key' } } - | /check/i '(' /[^)]+/ ')' - { $return = { type => 'check', expression => $item[3] } } + | /check/i check_expression + { + $return = { + type => 'check', + expression => $item[2], + }; + } | /references/i table_name parens_word_list(?) on_delete(?) { $return = { @@ -424,6 +427,18 @@ column_constraint_type : /not\s+null/i { $return = { type => 'not_null' } } } } +LPAREN : '(' + +RPAREN : ')' + +check_condition_text : /.+\s+in\s+\([^)]+\)/i + | /[^)]+/ + +check_expression : LPAREN check_condition_text RPAREN + { $return = join( ' ', map { $_ || () } + $item[1], $item[2], $item[3], $item[4][0] ) + } + constraint_state : deferrable { $return = { type => $item[1] } } | deferred { $return = { type => $item[1] } } | /(no)?rely/i { $return = { type => $item[1] } } @@ -555,11 +570,11 @@ table_constraint_type : /primary key/i '(' NAME(s /,/) ')' } } | - /check/ '(' /(.+)/ ')' + /check/i check_expression /^(en|dis)able/i { $return = { type => 'check', - expression => $item[3], + expression => join(' ', $item[2], $item[3]), } } | @@ -670,11 +685,14 @@ sub parse { name => $cdata->{'name'}, type => $cdata->{'type'}, fields => $cdata->{'fields'}, + expression => $cdata->{'expression'}, reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '', - on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'}, - on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'}, + on_delete => $cdata->{'on_delete'} + || $cdata->{'on_delete_do'}, + on_update => $cdata->{'on_update'} + || $cdata->{'on_update_do'}, ) or die $table->error; } } @@ -714,7 +732,7 @@ sub parse { =head1 AUTHOR -Ken Y. Clark Ekclark@cpan.orgE. +Ken Youens-Clark Ekclark@cpan.orgE. =head1 SEE ALSO