[Bast-commits] r6964 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class/Storage/DBI t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Fri Jul 3 11:19:28 GMT 2009


Author: ribasushi
Date: 2009-07-03 11:19:27 +0000 (Fri, 03 Jul 2009)
New Revision: 6964

Modified:
   DBIx-Class/0.08/trunk/Changes
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/mysql.pm
   DBIx-Class/0.08/trunk/t/71mysql.t
Log:
Add set_ansi_mode on_connect_call for mysql
Also switch to _do_query instead of plain dbh->do (shows up in the trace)

Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes	2009-07-03 10:49:16 UTC (rev 6963)
+++ DBIx-Class/0.08/trunk/Changes	2009-07-03 11:19:27 UTC (rev 6964)
@@ -6,6 +6,12 @@
         - New resultsed method count_rs, returns a ::ResultSetColumn
           which in turn returns a single count value
         - Even better support of count with limit
+        - New on_connect_call/on_disconnect_call functionality (check
+          POD of Storage::DBI)
+        - Automatic datetime handling environment/session setup for
+          Oracle via connect_call_datetime_setup()
+        - MySQL can now be turned into a sane database by adding
+          { on_connect_call => 'set_ansi_mode' } to the connect() call
         - count/all on related left-joined empty resultsets now correctly
           returns 0/()
         - Fixed regression when both page and offset are specified on

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/mysql.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/mysql.pm	2009-07-03 10:49:16 UTC (rev 6963)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/mysql.pm	2009-07-03 11:19:27 UTC (rev 6964)
@@ -10,15 +10,15 @@
 sub with_deferred_fk_checks {
   my ($self, $sub) = @_;
 
-  $self->dbh->do('SET foreign_key_checks=0');
+  $self->_do_query('SET foreign_key_checks=0');
   $sub->();
-  $self->dbh->do('SET foreign_key_checks=1');
+  $self->_do_query('SET foreign_key_checks=1');
 }
 
 sub connect_call_set_ansi_mode {
   my $self = shift;
-  $self->dbh->do(q|SET sql_mode = 'ANSI,TRADITIONAL'|);
-  $self->dbh->do(q|SET sql_mode = 'ANSI,TRADITIONAL'|);
+  $self->_do_query(q|SET sql_mode = 'ANSI,TRADITIONAL'|);
+  $self->_do_query(q|SET SQL_AUTO_IS_NULL = 0|);
 }
 
 sub _dbh_last_insert_id {

Modified: DBIx-Class/0.08/trunk/t/71mysql.t
===================================================================
--- DBIx-Class/0.08/trunk/t/71mysql.t	2009-07-03 10:49:16 UTC (rev 6963)
+++ DBIx-Class/0.08/trunk/t/71mysql.t	2009-07-03 11:19:27 UTC (rev 6964)
@@ -155,41 +155,36 @@
     is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
 }
 
+my $cd = $schema->resultset ('CD')->create ({});
+my $producer = $schema->resultset ('Producer')->create ({});
+lives_ok { $cd->set_producers ([ $producer ]) } 'set_relationship doesnt die';
+
+
 ## Can we properly deal with the null search problem?
 ##
 ## Only way is to do a SET SQL_AUTO_IS_NULL = 0; on connect
 ## But I'm not sure if we should do this or not (Ash, 2008/06/03)
+#
+# There is now a built-in function to do this, test that everything works
+# with it (ribasushi, 2009/07/03)
 
 NULLINSEARCH: {
-    
-    ok my $artist1_rs = $schema->resultset('Artist')->search({artistid=>6666})
-    => 'Created an artist resultset of 6666';
-    
+    my $ansi_schema = DBICTest::Schema->connect ($dsn, $user, $pass, { on_connect_call => 'set_ansi_mode' });
+
+    ok my $artist1_rs = $ansi_schema->resultset('Artist')->search({artistid=>6666})
+      => 'Created an artist resultset of 6666';
+
     is $artist1_rs->count, 0
-    => 'Got no returned rows';
-    
-    ok my $artist2_rs = $schema->resultset('Artist')->search({artistid=>undef})
-    => 'Created an artist resultset of undef';
-    
-    TODO: {
-    	local $TODO = "need to fix the row count =1 when select * from table where pk IS NULL problem";
-	    is $artist2_rs->count, 0
-	    => 'got no rows';    	
-    }
+      => 'Got no returned rows';
 
-    my $artist = $artist2_rs->single;
-    
-    is $artist => undef
-    => 'Nothing Found!';
-}
-    
-my $cd = $schema->resultset ('CD')->create ({});
+    ok my $artist2_rs = $ansi_schema->resultset('Artist')->search({artistid=>undef})
+      => 'Created an artist resultset of undef';
 
-my $producer = $schema->resultset ('Producer')->create ({});
+    is $artist2_rs->count, 0
+      => 'got no rows';
 
-lives_ok { $cd->set_producers ([ $producer ]) } 'set_relationship doesnt die';
+    my $artist = $artist2_rs->single;
 
-# clean up our mess
-END {
-    #$dbh->do("DROP TABLE artist") if $dbh;
+    is $artist => undef
+      => 'Nothing Found!';
 }




More information about the Bast-commits mailing list