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=fe58f774c0f2009ef492368a4420877672f9b014;hpb=4b8dd353a4ff88bb03a1c9705d8c016b959c3fbe;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm index fe58f77..c233361 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm @@ -39,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;