[Dbix-class] [TestCase] premature sql_maker initialization

Pedro Melo melo at simplicidade.org
Fri Oct 30 20:46:20 GMT 2009


Hi,

Attached is a new test case for the 71mysql.t file that tests the  
proper initialization of the sql_maker in the ::Storage::DBI class.

If the first query immediately after a connect is a find(), the code  
path will call sql_maker() before calling _determine_driver(), and so,  
any ::Storage::DBI subclass that updates sql_maker_class() will be  
unable to use the specific SQLHacks class. This a side effect of the  
code path that find() uses: it calls single() as a fast path, and that  
path doesn't call _determine_driver().

The patch covers only the MySQL database because, of those that have a  
SQLHacks subclass, thats the only one that I have access to.  
Equivalent tests could/should be done on the Oracle and MSSQL cases.

A probable solution would be to add something like this  
to ::Storage::DBI::select_single():

   # redispatch to update method of storage we reblessed into, if  
necessary
   if (not $self->_driver_determined) {
     $self->_determine_driver;
     goto $self->can('select_single');
   }

but for some obscure reason I cannot get it to work.

Best regards,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: premature_sql_maker_init.diff
Type: application/octet-stream
Size: 694 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20091030/6dac059e/premature_sql_maker_init.obj
-------------- next part --------------





More information about the DBIx-Class mailing list