package SQL::Translator::Parser::Access;
# -------------------------------------------------------------------
-# $Id: Access.pm,v 1.1 2004-04-19 16:38:17 kycl4rk 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
use strict;
use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/;
+$VERSION = '1.59';
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
field : field_name data_type field_qualifier(s?) reference_definition(?)
{
-# my %qualifiers = map { %$_ } @{ $item{'field_qualifier(s?)'} || [] };
-# if ( my @type_quals = @{ $item{'data_type'}{'qualifiers'} || [] } ) {
-# $qualifiers{ $_ } = 1 for @type_quals;
-# }
-#
-# my $null = defined $qualifiers{'not_null'}
-# ? $qualifiers{'not_null'} : 1;
-# delete $qualifiers{'not_null'};
-
$return = {
supertype => 'field',
name => $item{'field_name'},
data_type => $item{'data_type'}{'type'},
size => $item{'data_type'}{'size'},
-# null => $null,
constraints => $item{'reference_definition(?)'},
-# %qualifiers,
}
}
| <error>
}
}
-reference_definition : /references/i table_name parens_field_list(?) match_type(?) on_delete_do(?) on_update_do(?)
+reference_definition : /references/i table_name parens_field_list(?) match_type(?) on_delete(?) on_update(?)
{
$return = {
type => 'foreign_key',
reference_table => $item[2],
reference_fields => $item[3][0],
match_type => $item[4][0],
- on_delete_do => $item[5][0],
- on_update_do => $item[6][0],
+ on_delete => $item[5][0],
+ on_update => $item[6][0],
}
}
|
/match partial/i { 'partial' }
-on_delete_do : /on delete/i reference_option
+on_delete : /on delete/i reference_option
{ $item[2] }
-on_update_do : /on update/i reference_option
+on_update : /on update/i reference_option
{ $item[2] }
reference_option: /restrict/i |
) or die $table->error;
$table->primary_key( $field->name ) if $fdata->{'is_primary_key'};
-
-# for my $qual ( qw[ binary unsigned zerofill list ] ) {
-# if ( my $val = $fdata->{ $qual } || $fdata->{ uc $qual } ) {
-# next if ref $val eq 'ARRAY' && !@$val;
-# $field->extra( $qual, $val );
-# }
-# }
-
-# for my $cdata ( @{ $fdata->{'constraints'} } ) {
-# next unless $cdata->{'type'} eq 'foreign_key';
-# $cdata->{'fields'} ||= [ $field->name ];
-# push @{ $tdata->{'constraints'} }, $cdata;
-# }
}
for my $idata ( @{ $tdata->{'indices'} || [] } ) {
fields => $idata->{'fields'},
) or die $table->error;
}
-
-# for my $cdata ( @{ $tdata->{'constraints'} || [] } ) {
-# my $constraint = $table->add_constraint(
-# name => $cdata->{'name'},
-# type => $cdata->{'type'},
-# fields => $cdata->{'fields'},
-# reference_table => $cdata->{'reference_table'},
-# reference_fields => $cdata->{'reference_fields'},
-# match_type => $cdata->{'match_type'} || '',
-# on_delete => $cdata->{'on_delete_do'},
-# on_update => $cdata->{'on_update_do'},
-# ) or die $table->error;
-# }
}
return 1;