Revision history for DBIx::Class
+ - Fixed superfluous connection in ODBC::_rebless
+ - Fixed undef PK for first insert in ODBC::Microsoft_SQL_Server
0.08099_04 2008-07-24 01:00:00
- Functionality to storage to enable a sub to be run without FK checks
my $ident = $source->from;
my $bind_attributes = $self->source_bind_attributes($source);
+ $self->ensure_connected;
foreach my $col ( $source->columns ) {
if ( !defined $to_insert->{$col} ) {
my $col_info = $source->column_info($col);
if ( $col_info->{auto_nextval} ) {
- $self->ensure_connected;
$to_insert->{$col} = $self->_sequence_fetch( 'nextval', $col_info->{sequence} || $self->_dbh_get_autoinc_seq($self->dbh, $source) );
}
}
sub _rebless {
my ($self) = @_;
- my $dbh = $self->dbh;
- my $dbtype = eval { $dbh->get_info(17) };
+ my $dbtype = eval { $self->_dbh->get_info(17) };
unless ( $@ ) {
# Translate the backend name into a perl identifier
$dbtype =~ s/\W/_/gi;
return ($sql, $bind);
}
-sub insert {
- my ($self, $source, $to_insert) = @_;
+sub _execute {
+ my $self = shift;
+ my ($op) = @_;
- my $bind_attributes = $self->source_bind_attributes($source);
- my (undef, $sth) = $self->_execute( 'insert' => [], $source, $bind_attributes, $to_insert);
- $self->{_scope_identity} = $sth->fetchrow_array;
+ my ($rv, $sth, @bind) = $self->dbh_do($self->can('_dbh_execute'), @_);
+ $self->{_scope_identity} = $sth->fetchrow_array if $op eq 'insert';
- return $to_insert;
+ return wantarray ? ($rv, $sth, @bind) : $rv;
}
sub last_insert_id { shift->{_scope_identity} }
=head1 METHODS
-=head2 insert
-
=head2 last_insert_id
=head2 sqlt_type
$schema->storage->ensure_connected;
isa_ok( $schema->storage, 'DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server' );
-my $dbh = $schema->storage->dbh;
+my $dbh = $schema->storage->_dbh;
eval { $dbh->do("DROP TABLE artist") };
CREATE TABLE artist (
artistid INT IDENTITY NOT NULL,
name VARCHAR(255),
- charfield CHAR(10),
+ charfield CHAR(10) NULL,
primary key(artistid)
)
my %seen_id;
+# fresh $schema so we start unconnected
+$schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
+
# test primary key handling
my $new = $schema->resultset('Artist')->create({ name => 'foo' });
ok($new->artistid > 0, "Auto-PK worked");
# clean up our mess
END {
+ $dbh = eval { $schema->storage->_dbh };
$dbh->do('DROP TABLE artist') if $dbh;
}