From: Rafael Kitover Date: Sat, 30 Jan 2010 23:25:47 +0000 (+0000) Subject: set data_type to undef for Sybase computed columns X-Git-Tag: 0.05000~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=db4d62ad76d4158da4d2de5228f63435459c4509;hp=de82711a0abb69a8f67fc81e5e27f627d7053bf2;p=dbsrgits%2FDBIx-Class-Schema-Loader.git set data_type to undef for Sybase computed columns --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm index e6643d6..c1cef54 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm @@ -229,6 +229,31 @@ sub _table_uniq_info { return \@uniqs; } +# set data_type to 'undef' for computed columns +sub _columns_info_for { + my $self = shift; + my ($table) = @_; + my $result = $self->next::method(@_); + + my $dbh = $self->schema->storage->dbh; + my $sth = $dbh->prepare(qq{ +SELECT c.name name, c.computedcol computedcol +FROM syscolumns c +JOIN sysobjects o ON c.id = o.id +WHERE o.name = @{[ $dbh->quote($table) ]} AND o.type = 'U' +}); + $sth->execute; + local $dbh->{FetchHashKeyName} = 'NAME_lc'; + my $computed_info = $sth->fetchall_hashref('name'); + + for my $col (keys %$result) { + $result->{$col}{data_type} = undef + if $computed_info->{$col}{computedcol}; + } + + return $result; +} + sub _extra_column_info { my ($self, $info) = @_; my %extra_info; diff --git a/t/15sybase_common.t b/t/15sybase_common.t index 847b253..623af02 100644 --- a/t/15sybase_common.t +++ b/t/15sybase_common.t @@ -64,16 +64,12 @@ my $tester = dbixcsl_common_tests->new( 10, 'VARCHAR(10) has correct size'; - { - local $TODO = 'data_type for computed columns'; - - ok ((exists $rsrc->column_info('computed_dt')->{data_type} - && (not defined $rsrc->column_info('computed_dt')->{data_type})), - 'data_type for computed column exists and is undef') -# or diag "Data type is: ", -# $rsrc->column_info('computed_dt')->{data_type} - ; - } + ok ((exists $rsrc->column_info('computed_dt')->{data_type} + && (not defined $rsrc->column_info('computed_dt')->{data_type})), + 'data_type for computed column exists and is undef') + or diag "Data type is: ", + $rsrc->column_info('computed_dt')->{data_type} + ; }, }, );