[Catalyst] CDBI::Sweet pagination minor problem.

Emanuele Zeppieri ema_zep at libero.it
Mon Jul 11 14:51:27 CEST 2005


Hi Matt, hi list.

I've seen that, to paginate the returned records, CDBI::Sweet (cleverly)
tries to check if the underlying DBMS supports the LIMIT/OFFSET-like
clauses and uses them where available, otherwise it resorts to slicing
the CDBI iterator object.

So far, so good.
Very good indeed! :-)

The only problem here is that, to check if (and what of) the
LIMIT/OFFSET-like clauses are supported, CDBI::Sweet asks for the DBI
*driver* being used, while we're interested in the DBMS, which not
always coincides with the driver.

Think of DBD::ODBC for example: if you ask for the driver in use, it
simply returns the string "ODBC", while we could have (nearly) any DBMS
beneath the driver, which name is shadowed by the driver name, so in
this case we ultimately cannot correctly decide if the DBMS in use
supports LIMIT/OFFSET or not.

So I would suggest to change the following line in sub _search:

my $driver = lc $class->db_Main->{Driver}->{Name};

to:

use DBI::Const::GetInfoType;
my $dbms = lc $class->db_Main->get_info( $GetInfoType{SQL_DBMS_NAME} );

or to the simpler (but less modular):

my $dbms = lc $class->db_Main->get_info( 17 );

which returns the name of the /real/ DBMS in use, regardless of the DBI
driver being used.

Then, the subsequent test on the returned string in sub _search should
be changed as well, since the values returned by get_info(17) are a
little different from the values returned by db_Main->{Driver}->{Name}
(if you use Postgres for example, the latter returns the string "Pg"
while the former returns the string "PostgreSQL" - again, even if you
are using DBD::ODBC ;-)

I'm really sorry I can't provide the full list of the values returned by
get_info(17), but I've got only Postgres (and IBM DB2) installed here.

Does this make any sense?

Ciao,
Emanuele.




More information about the Catalyst mailing list