X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase%2FASE.pm;h=e3485ce09cd18c1da1989b38fb0b0cfff348f20d;hp=91bf586df63365e59a9a90cca00e7bacd41854f1;hb=0777ad33930b2c09258f9752e4e76c27ca75f347;hpb=b946a283391c836663b4238c681c1a6f62f75394 diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm index 91bf586..e3485ce 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm @@ -353,10 +353,19 @@ sub insert { # check for empty insert # INSERT INTO foo DEFAULT VALUES -- does not work with Sybase - # try to insert explicit 'DEFAULT's instead (except for identity) + # try to insert explicit 'DEFAULT's instead (except for identity, timestamp + # and computed columns) if (not %$to_insert) { for my $col ($source->columns) { next if $col eq $identity_col; + + my $info = $source->column_info($col); + + next if ref $info->{default_value} eq 'SCALAR' + || (exists $info->{data_type} && (not defined $info->{data_type})); + + next if $info->{data_type} && $info->{data_type} =~ /^timestamp\z/i; + $to_insert->{$col} = \'DEFAULT'; } } @@ -933,12 +942,8 @@ sub _svp_rollback { =head1 Schema::Loader Support -There is an experimental branch of L that will -allow you to dump a schema from most (if not all) versions of Sybase. - -It is available via subversion from: - - http://dev.catalyst.perl.org/repos/bast/branches/DBIx-Class-Schema-Loader/current/ +As of version C<0.05000>, L should work well with +most (if not all) versions of Sybase ASE. =head1 FreeTDS @@ -1091,6 +1096,42 @@ loading your app, if it doesn't match the character set of your database. When inserting IMAGE columns using this method, you'll need to use L as well. +=head1 COMPUTED COLUMNS + +If you have columns such as: + + created_dtm AS getdate() + +represent them in your Result classes as: + + created_dtm => { + data_type => undef, + default_value => \'getdate()', + is_nullable => 0, + } + +The C must exist and must be C. Then empty inserts will work +on tables with such columns. + +=head1 TIMESTAMP COLUMNS + +C columns in Sybase ASE are not really timestamps, see: +L. + +They should be defined in your Result classes as: + + ts => { + data_type => 'timestamp', + is_nullable => 0, + inflate_datetime => 0, + } + +The C< 0>> is necessary if you use +L, and most people do, and still want to +be able to read these values. + +The values will come back as hexadecimal. + =head1 TODO =over