From: Ross Smith II Date: Sun, 17 Aug 2003 01:11:54 +0000 (+0000) Subject: Added quotes around ENUM values in CONSTRAINT for Oracle & Sybase. X-Git-Tag: v0.04~314 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77d74ea6cb99a76389e062e4cad55b2d749c72ce;p=dbsrgits%2FSQL-Translator.git Added quotes around ENUM values in CONSTRAINT for Oracle & Sybase. This change is untested as I do not have access to these right now. --- diff --git a/lib/SQL/Translator/Producer/Oracle.pm b/lib/SQL/Translator/Producer/Oracle.pm index 849c4a9..e03ed40 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.17 2003-08-15 16:26:44 kycl4rk Exp $ +# $Id: Oracle.pm,v 1.18 2003-08-17 01:11:54 rossta 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.17 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.18 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -174,7 +174,8 @@ sub produce { my @size = $field->size; my %extra = $field->extra; my $list = $extra{'list'} || []; - my $commalist = join ",", @$list; + # \todo deal with embedded quotes + my $commalist = "'" . (join "', '", @$list) . "'"; if ( $data_type eq 'enum' ) { $check = "CHECK ($field_name IN ($commalist))"; diff --git a/lib/SQL/Translator/Producer/Sybase.pm b/lib/SQL/Translator/Producer/Sybase.pm index bb89bef..5e41140 100644 --- a/lib/SQL/Translator/Producer/Sybase.pm +++ b/lib/SQL/Translator/Producer/Sybase.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Sybase; # ------------------------------------------------------------------- -# $Id: Sybase.pm,v 1.4 2003-06-11 04:00:44 kycl4rk Exp $ +# $Id: Sybase.pm,v 1.5 2003-08-17 01:11:54 rossta Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark , # darren chamberlain , @@ -31,7 +31,7 @@ SQL::Translator::Producer::Sybase - Sybase producer for SQL::Translator use strict; use vars qw[ $DEBUG $WARN $VERSION ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; use Data::Dumper; @@ -171,7 +171,8 @@ sub produce { my $orig_data_type = $data_type; my %extra = $field->extra; my $list = $extra{'list'} || []; - my $commalist = join ",", @$list; + # \todo deal with embedded quotes + my $commalist = "'" . join("','", @$list) . "'"; my $seq_name; if ( $data_type eq 'enum' ) {