Skip Menu |

This queue is for tickets about the Class-DBI-DATA-Schema CPAN distribution.

Report information
The Basics
Id: 6827
Status: resolved
Priority: 0/
Queue: Class-DBI-DATA-Schema

People
Owner: Nobody in particular
Requestors: perl [...] walker.wattle.id.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.04
Fixed in: 1.00



Subject: Translation caching breaks installs on different databases
Class::DBI::DATA::Schema 0.04 If I install into one database and then try and install into another the cached version is used and may fail if the sql dialect has differences. I'd suggest that the from and to database types are added to the sql for the MD5 hash or to the cache_root resulting in a separate cache for each translation type. At the very least a warning in the docs would be good. Thanks Matthew
Date: Fri, 2 Jul 2004 08:06:43 +0100
From: Tony Bowden <tony [...] kasei.com>
To: Guest via RT <bug-Class-DBI-DATA-Schema [...] rt.cpan.org>
Subject: Re: [cpan #6827] Translation caching breaks installs on different databases
RT-Send-Cc:
On Fri, Jul 02, 2004 at 12:07:49AM -0400, Guest via RT wrote: Show quoted text
> If I install into one database and then try and install into > another the cached version is used and may fail if the sql dialect has > differences. I'd suggest that the from and to database types are added > to the sql for the MD5 hash or to the cache_root resulting in a separate > cache for each translation type. At the very least a warning in the docs > would be good.
I think it must be too early in the morning, but I don't quite follow what you're doing to trigger this. Can you give an example? Thanks, Tony
From: matthew [...] walker.wattle.id.au
[tony@kasei.com - Fri Jul 2 03:30:16 2004]: Show quoted text
> On Fri, Jul 02, 2004 at 12:07:49AM -0400, Guest via RT wrote:
> > If I install into one database and then try and install into > > another the cached version is used and may fail if the sql dialect
> has
> > differences. I'd suggest that the from and to database types are
> added
> > to the sql for the MD5 hash or to the cache_root resulting in a
> separate
> > cache for each translation type. At the very least a warning in the
> docs
> > would be good.
> > I think it must be too early in the morning, but I don't quite follow > what you're doing to trigger this. Can you give an example?
Tony, reading it again I think that's understandable. Thanks for following up. Here's the steps I can take to cause the problem: I am using a class that uses Class::DBI::DATA::Schema and passes a cache parameter when calling import. The sql DATA in my class is for a mysql database. When using that class to create a new database of say sqlite that is the translation that is stored in the cache. If I then create a new database bit instead use postgres Class::DBI::DATA::Schema sees the cached translation and just returns that and postgres doesn't like that dialect and spits the dummy. If you add the from and to database types to the sql to be MD5'd and compared to the cache then the MD5 will be different and cause the sql to be translated again and a new cache created. Alternately you could create a separate cache for each pair of database types. Below is the simple patch I made, but it may not be the best solution. Thanks Matthew --- /Users/matthew/.cpan/build/Class-DBI-DATA-Schema-0.04/lib/Class/DBI/DATA/ Schema.pm Wed Mar 17 20:53:11 2004 +++ /Library/Perl/5.8.1/Class/DBI/DATA/Schema.pm Fri Jul 2 15:41:27 2004 @@ -80,7 +80,7 @@ my $translate = sub { my $sql = shift; if (my ($from, $to) = @{ $args{translate} || [] }) { - my $key = $CACHE ? Digest::MD5::md5_base64($sql) : ""; + my $key = $CACHE ? Digest::MD5::md5_base64($sql.$from.$to) : ""; my $cached = $CACHE ? $CACHE->get($key) : ""; return $cached if $cached;
[guest - Fri Jul 2 09:04:05 2004]: Show quoted text
> Below is the simple patch I made, but it may not be the best solution. > if (my ($from, $to) = @{ $args{translate} || [] }) { > - my $key = $CACHE ? > Digest::MD5::md5_base64($sql) : ""; > + my $key = $CACHE ? > Digest::MD5::md5_base64($sql.$from.$to) : "";
Sorry for the delay. I went ahead and applied this just like that. Hope that helps for you. New version on CPAN now. Thanks, Tony