From: Ken Youens-Clark Date: Sat, 4 Oct 2003 01:21:10 +0000 (+0000) Subject: Don't make up unnecessary monikers, added support for table options that X-Git-Tag: v0.04~131 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=02c2af3bc9ab7ccb052808e64307c58fce36df7a;p=dbsrgits%2FSQL-Translator.git Don't make up unnecessary monikers, added support for table options that DDL::Oracle has. --- diff --git a/lib/SQL/Translator/Producer/Oracle.pm b/lib/SQL/Translator/Producer/Oracle.pm index 55f1d59..d25b227 100644 --- a/lib/SQL/Translator/Producer/Oracle.pm +++ b/lib/SQL/Translator/Producer/Oracle.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Oracle; # ------------------------------------------------------------------- -# $Id: Oracle.pm,v 1.24 2003-08-27 02:28:21 kycl4rk Exp $ +# $Id: Oracle.pm,v 1.25 2003-10-04 01:21:10 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark , # darren chamberlain , @@ -24,7 +24,7 @@ package SQL::Translator::Producer::Oracle; use strict; use vars qw[ $VERSION $DEBUG $WARN ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.24 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.25 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -264,10 +264,11 @@ sub produce { # Not null constraint # unless ( $field->is_nullable ) { - my $constraint_name = mk_name( - join('_', $table_name_ur, $field_name_ur ), 'nn' - ); - $field_def .= ' CONSTRAINT ' . $constraint_name . ' NOT NULL'; +# my $constraint_name = mk_name( +# join('_', $table_name_ur, $field_name_ur ), 'nn' +# ); +# $field_def .= ' CONSTRAINT ' . $constraint_name . ' NOT NULL'; + $field_def .= ' NOT NULL'; } $field_def .= " $check" if $check; @@ -318,6 +319,29 @@ sub produce { } # + # Table options + # + my @table_options; + for my $opt ( $table->options ) { + if ( ref $opt eq 'HASH' ) { + my ( $key, $value ) = each %$opt; + if ( ref $value eq 'ARRAY' ) { + push @table_options, "$key\n(\n". join ("\n", + map { " $_->[0]\t$_->[1]" } + map { [ each %$_ ] } + @$value + )."\n)"; + } + elsif ( !defined $value ) { + push @table_options, $key; + } + else { + push @table_options, "$key $value"; + } + } + } + + # # Table constraints # for my $c ( $table->get_constraints ) { @@ -416,9 +440,11 @@ sub produce { } } + my $table_options = @table_options + ? "\n".join("\n", @table_options) : ''; $create_statement .= "CREATE TABLE $table_name_ur (\n" . join( ",\n", map { " $_" } @field_defs, @constraint_defs ) . - "\n);" + "\n)$table_options;" ; $output .= join( "\n\n",