[Bast-commits] r9051 - in DBIx-Class/0.08/trunk:
lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI
lib/DBIx/Class/Storage/DBI/ODBC t
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed Mar 24 20:25:24 GMT 2010
Author: caelum
Date: 2010-03-24 20:25:24 +0000 (Wed, 24 Mar 2010)
New Revision: 9051
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Pg.pm
DBIx-Class/0.08/trunk/t/72pg.t
Log:
collect _server_info on connection
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm 2010-03-24 19:44:15 UTC (rev 9050)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm 2010-03-24 20:25:24 UTC (rev 9051)
@@ -178,7 +178,7 @@
sub _get_mssql_version {
my $self = shift;
- my ($version) = $self->_get_dbh->get_info(18) =~ /^(\d+)/;
+ my ($version) = $self->_server_info->{dbms_ver} =~ /^(\d+)/;
return $version;
}
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Pg.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Pg.pm 2010-03-24 19:44:15 UTC (rev 9050)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Pg.pm 2010-03-24 20:25:24 UTC (rev 9051)
@@ -19,10 +19,8 @@
sub can_insert_returning {
my $self = shift;
- my $pg_ver = $self->_get_dbh->get_info(18);
+ my ($major, $minor) = $self->_server_info->{dbms_ver} =~ /^(\d+)\.(\d+)/;
- my ($major, $minor) = $pg_ver =~ /^(\d+)\.(\d+)/;
-
return 1
if ($major > 8) || ($major == 8 && $minor >= 2);
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2010-03-24 19:44:15 UTC (rev 9050)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2010-03-24 20:25:24 UTC (rev 9051)
@@ -18,7 +18,8 @@
__PACKAGE__->mk_group_accessors('simple' =>
qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts _conn_pid
- _conn_tid transaction_depth _dbh_autocommit _driver_determined savepoints/
+ _conn_tid transaction_depth _dbh_autocommit _driver_determined savepoints
+ _server_info/
);
# the values for these accessors are picked out (and deleted) from
@@ -919,6 +920,8 @@
$self->{transaction_depth} = $self->_dbh_autocommit ? 0 : 1;
$self->_run_connection_actions unless $self->{_in_determine_driver};
+
+ $self->_get_server_info;
}
sub _run_connection_actions {
@@ -931,6 +934,17 @@
$self->_do_connection_actions(connect_call_ => $_) for @actions;
}
+sub _get_server_info {
+ my $self = shift;
+ my %info;
+
+ $info{dbms_ver} = $self->_get_dbh->get_info(18);
+
+ $self->_server_info(\%info);
+
+ return \%info;
+}
+
sub _determine_driver {
my ($self) = @_;
Modified: DBIx-Class/0.08/trunk/t/72pg.t
===================================================================
--- DBIx-Class/0.08/trunk/t/72pg.t 2010-03-24 19:44:15 UTC (rev 9050)
+++ DBIx-Class/0.08/trunk/t/72pg.t 2010-03-24 20:25:24 UTC (rev 9051)
@@ -25,9 +25,13 @@
my $schema;
+require DBIx::Class::Storage::DBI::Pg;
+
+my $can_insert_returning =
+ DBIx::Class::Storage::DBI::Pg->can('can_insert_returning');
+
for my $use_insert_returning (0..1) {
no warnings qw/redefine once/;
- require DBIx::Class::Storage::DBI::Pg;
local *DBIx::Class::Storage::DBI::Pg::can_insert_returning = sub {
$use_insert_returning
};
@@ -63,7 +67,15 @@
### connect, create postgres-specific test schema
$schema = DBICTest::Schema->connect($dsn, $user, $pass);
+ $schema->storage->ensure_connected;
+ if ($use_insert_returning && (not $can_insert_returning->($schema->storage)))
+ {
+ diag "Your version of PostgreSQL does not support INSERT ... RETURNING.";
+ diag "*** SKIPPING FURTHER TESTS";
+ last;
+ }
+
drop_test_schema($schema);
create_test_schema($schema);
More information about the Bast-commits
mailing list