[TestCase] premature sql_maker initialization

3 messages Options
Embed this post
Permalink
Pedro Melo

[TestCase] premature sql_maker initialization

Reply Threaded More More options
Print post
Permalink
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,







_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...

premature_sql_maker_init.diff (714 bytes) Download Attachment
Pedro Melo

Re: [TestCase] premature sql_maker initialization

Reply Threaded More More options
Print post
Permalink
Hi again,


On Fri, Oct 30, 2009 at 8:46 PM, Pedro Melo <[hidden email]> wrote:
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.

I got it to work. The attached patch fixes the problem for MySQL.

Best regards


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...

select_single_init.diff (964 bytes) Download Attachment
Peter Rabbitson-2

Re: Re: [TestCase] premature sql_maker initialization

Reply Threaded More More options
Print post
Permalink
Pedro Melo wrote:

> Hi again,
>
>
> On Fri, Oct 30, 2009 at 8:46 PM, Pedro Melo <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     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.
>
>
> I got it to work. The attached patch fixes the problem for MySQL.
>

Fixed in a more general way:
http://dev.catalyst.perl.org/svnweb/bast/revision/?rev=7863

Cheers

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...