Subject: | Oracle parser patch to fix quoted names and triggers |
The Oracle parser doesn't seem to handle quoted names (related to bug
#58318: can't turn off quoted table names) and triggers.
The schema handles triggers, so the patch attached adds introductory
support for triggers. The patch also effectively ignores quotes around
names.
I didn't bother writing any .t to verify this, sorry :(
Subject: | Oracle.pm.diff |
--- /home/zitz/Oracle.pm 2010-11-11 12:08:33.000000000 -0600
+++ Oracle.pm 2010-11-11 12:40:02.875936002 -0600
@@ -112,7 +112,7 @@
$GRAMMAR = q`
-{ my ( %tables, %indices, %constraints, $table_order, @table_comments, %views, $view_order, %procedures, $proc_order ) }
+{ my ( %tables, %indices, %constraints, $table_order, @table_comments, %views, $view_order, %procedures, $proc_order, %triggers, $trigger_order ) }
#
# The "eofile" rule makes the parser fail if any "statement" rule
@@ -128,6 +128,7 @@
constraints => \%constraints,
views => \%views,
procedures => \%procedures,
+ triggers => \%triggers,
};
}
@@ -221,6 +222,21 @@
$return = "$item[2]($arg_list)";
}
+create : /create/i /or replace/i /trigger/i table_name not_end m#^/$#im
+ {
+ @table_comments = ();
+ my $trigger_name = $item[4];
+ # Hack to strip owner from trigger name
+ $trigger_name =~ s#.*\.##;
+ my $owner = '';
+ my $action = "$item[1] $item[2] $item[3] $item[4] $item[5]";
+
+ $triggers{ $trigger_name }{'order'} = ++$trigger_order;
+ $triggers{ $trigger_name }{'name'} = $trigger_name;
+ $triggers{ $trigger_name }{'owner'} = $owner;
+ $triggers{ $trigger_name }{'action'} = $action;
+ }
+
create : /create/i /or replace/i /procedure/i table_name not_end m#^/$#im
{
@table_comments = ();
@@ -598,0 +614,0 @@
WORD : /\w+/
-NAME : /\w+/ { $item[1] }
+NAME : '"' /\w+/ '"'
+ { $item[2] }
+ |
+ /\w+/
+ { $item[1] }
+
TABLE : /table/i
@@ -718,6 +740,16 @@
);
}
+ my @triggers = sort {
+ $result->{triggers}->{ $a }->{'order'} <=> $result->{triggers}->{ $b }->{'order'}
+ } keys %{ $result->{triggers} };
+ foreach my $trigger_name (@triggers) {
+ $schema->add_trigger(
+ name => $trigger_name,
+ action => $result->{triggers}->{$trigger_name}->{action},
+ );
+ }
+
return 1;
}