[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;