Skip Menu |

This queue is for tickets about the SQL-Abstract-Limit CPAN distribution.

Report information
The Basics
Id: 15000
Status: resolved
Priority: 0/
Queue: SQL-Abstract-Limit

People
Owner: Nobody in particular
Requestors: support [...] 2rad.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.101
Fixed in: (no value)



Subject: _find_syntax() can throw a die due to the eval()
I noticed a couple problems. First, using Class::DBI it didn't seem to auto-pickup that I was using MySQL and instead was trying to use GenericQ. Secondly, when I manually set limit_dialect=>'LimitXY' it would croak. The reason is that we overload the die, so the eval was attempting: if ( eval { $syntax->{Driver}->{Name} } ) when $syntax was the string "LimitXY". Not sure this patch is a great solution, but swapping the order allowed it to run the string test BEFORE trying the eval. This error may not be obvious to those who do not override die. Thanks!
288c288,295 < if ( UNIVERSAL::isa( $syntax, 'Class::DBI' ) ) --- > # if ( UNIVERSAL::isa( $syntax, 'DBI::db' ) ) should work too > if ( eval { $syntax->{Driver}->{Name} } ) > { # DBI database handle > my $db = $self->_find_database_from_dbh( $syntax ); > return $self->_find_syntax_from_database( $db ); > } > > if ( UNIVERSAL::isa( $syntax, 'Class::DBI' ) ) 305,312d311 < # if ( UNIVERSAL::isa( $syntax, 'DBI::db' ) ) should work too < if ( eval { $syntax->{Driver}->{Name} } ) < { # DBI database handle < my $db = $self->_find_database_from_dbh( $syntax ); < return $self->_find_syntax_from_database( $db ); < } < <
[guest - Mon Oct 10 13:04:15 2005]: Show quoted text
> I noticed a couple problems. First, using Class::DBI it didn't seem to > auto-pickup that I was using MySQL and instead was trying to use > GenericQ.
Can you show how you were creating the SQL::Abstract::Limit object? Note that even for syntax auto-detection, you still need to pass something in the limit_dialect argument. What version of SQL::Abstract? What version of MySQL? Do you get a warning - "can't determine syntax model for XXX - using default at ..." - if so, what's XXX? Show quoted text
> Secondly, when I manually set limit_dialect=>'LimitXY' it > would croak. The reason is that we overload the die, so the eval > was attempting: > > if ( eval { $syntax->{Driver}->{Name} } ) > > when $syntax was the string "LimitXY". Not sure this patch is a great > solution, but swapping the order allowed it to run the string test > BEFORE trying the eval. This error may not be obvious to those who > do not override die. > > Thanks!
Thanks for this, I've re-arranged the tests in _find_syntax() and uploaded version 0.11. Cheers, d.
[mark@2rad.net - Tue Oct 11 12:05:53 2005]: Show quoted text
> > @suggestions = Entity::Keyword->search_where( { keyword => { 'like', > "$search\%" } }, { order_by => 'keyword', limit_dialect => 'LimitXY', > limit => 6, offset => 0, } ); > > Entity::Keyword is a Class::DBI object. I just simply didn't give it a > limit_dialect, as I was under the (wrong?) impression it would know > the > driver coming from a Class::DBI object. >
No, I guess I could probably hunt down the CDBI parent, but at the moment you have to pass limit_dialect explicitly. Note that you can pass the CDBI class or an instance instead of the literal dialect name. d.