X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSQLAnywhere.pm;h=c233361df4f575083b84bbc31dfe9489d0186714;hb=b979420a9fa5c170a4b926882051f800c132750b;hp=623a8e1c29dcf539f7d887b6f7e1344144c46756;hpb=2b0076be05baf00b0b4928a237ab43f377233fd4;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm index 623a8e1..c233361 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm @@ -16,8 +16,9 @@ DBIx::Class::Storage::DBI::SQLAnywhere - Driver for Sybase SQL Anywhere =head1 DESCRIPTION -This class implements autoincrements for Sybase SQL Anywhere and selects the -RowNumberOver limit implementation. +This class implements autoincrements for Sybase SQL Anywhere, selects the +RowNumberOver limit implementation and provides +L support. You need the C driver that comes with the SQL Anywhere distribution, B the one on CPAN. It is usually under a path such as: @@ -38,17 +39,21 @@ sub insert { my $self = shift; my ($source, $to_insert) = @_; - my $supplied_col_info = $self->_resolve_column_info($source, [keys %$to_insert]); - - my $is_identity_insert = (List::Util::first { $_->{is_auto_increment} } (values %$supplied_col_info) ) - ? 1 - : 0; - my $identity_col = List::Util::first { $source->column_info($_)->{is_auto_increment} } $source->columns; - if ((not $is_identity_insert) && $identity_col) { +# user might have an identity PK without is_auto_increment + if (not $identity_col) { + foreach my $pk_col ($source->primary_columns) { + if (not exists $to_insert->{$pk_col}) { + $identity_col = $pk_col; + last; + } + } + } + + if ($identity_col && (not exists $to_insert->{$identity_col})) { my $dbh = $self->_get_dbh; my $table_name = $source->from; $table_name = $$table_name if ref $table_name;