X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FDB2.pm;h=b996dabdc56081434e6b0ee380607d14be23dde7;hb=b511f36e7550cfe8aac546be689c8bd320a83975;hp=886a45b7623d4a6b1aabb1c4e1992bd3a2ab563b;hpb=bc1cb85e84e6a30c75763edd478378a68009c722;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm index 886a45b..b996dab 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm @@ -41,6 +41,10 @@ sub _setup { if (not defined $self->preserve_case) { $self->preserve_case(0); } + elsif ($self->preserve_case) { + $self->schema->storage->sql_maker->quote_char('"'); + $self->schema->storage->sql_maker->name_sep('.'); + } } sub _table_uniq_info { @@ -58,12 +62,12 @@ sub _table_uniq_info { WHERE tc.TABSCHEMA = ? and tc.TABNAME = ? and tc.TYPE = 'U'} ) or die $DBI::errstr; - $sth->execute($self->db_schema, uc $table) or die $DBI::errstr; + $sth->execute($self->db_schema, $self->_uc($table)) or die $DBI::errstr; my %keydata; while(my $row = $sth->fetchrow_arrayref) { my ($col, $constname, $seq) = @$row; - push(@{$keydata{$constname}}, [ $seq, lc $col ]); + push(@{$keydata{$constname}}, [ $seq, $self->_lc($col) ]); } foreach my $keyname (keys %keydata) { my @ordered_cols = map { $_->[1] } sort { $a->[0] <=> $b->[0] } @@ -81,7 +85,7 @@ sub _tables_list { my ($self, $opts) = @_; my $dbh = $self->schema->storage->dbh; - my @tables = map { lc } $dbh->tables( + my @tables = map $self->_lc($_), $dbh->tables( $self->db_schema ? { TABLE_SCHEM => $self->db_schema } : undef ); s/\Q$self->{_quoter}\E//g for @tables; @@ -92,16 +96,16 @@ sub _tables_list { sub _table_pk_info { my ($self, $table) = @_; - return $self->next::method(uc $table); + return $self->next::method($self->_uc($table)); } sub _table_fk_info { my ($self, $table) = @_; - my $rels = $self->next::method(uc $table); + my $rels = $self->next::method($self->_uc($table)); foreach my $rel (@$rels) { - $rel->{remote_table} = lc $rel->{remote_table}; + $rel->{remote_table} = $self->_lc($rel->{remote_table}); } return $rels; @@ -111,7 +115,7 @@ sub _columns_info_for { my $self = shift; my ($table) = @_; - my $result = $self->next::method(uc $table); + my $result = $self->next::method($self->_uc($table)); my $dbh = $self->schema->storage->dbh; @@ -125,14 +129,17 @@ sub _columns_info_for { AND identity = 'Y' AND generated != '' }, {}, 1); - $sth->execute($self->db_schema, uc $table, uc $col); + $sth->execute($self->db_schema, $self->_uc($table), $self->_uc($col)); if ($sth->fetchrow_array) { $info->{is_auto_increment} = 1; } - if (eval { lc ${ $info->{default_value} } }||'' eq 'current timestamp') { - ${ $info->{default_value} } = 'CURRENT_TIMESTAMP'; + if ((eval { lc ${ $info->{default_value} } }||'') eq 'current timestamp') { + ${ $info->{default_value} } = 'current_timestamp'; delete $info->{size}; + + my $orig_deflt = 'current timestamp'; + $info->{original}{default_value} = \$orig_deflt; } }