[CDBI] Fwd: issues with utf8?

Jim Lambert jlambert at brandeis.edu
Tue Nov 28 15:51:19 GMT 2006


I follow-up to my mail from last night....

I've been able to retrieve my HasMany relationship objects by making  
the following change to Class::DBI::Relationship::HasMany:

sub _hm_run_search {
         my $rel = shift;
         my ($class, $accessor) = ($rel->class, $rel->accessor);
         return sub {
             my ($self, @search_args) = @_;
             @search_args = %{ $search_args[0] } if ref $search_args 
[0] eq "HASH";
             my $meta = $class->meta_info($rel->name => $accessor);
             my ($f_class, $f_key, $args) =
                 ($meta->foreign_class, $meta->args->{foreign_key},  
$meta->args);
             if (ref $self) {    # For $artist->cds
		unshift @search_args, %{ $args->{constraint} }
                     if defined($args->{constraint}) && ref $args-> 
{constraint} eq 'HASH';

                 ## this-is-the-change
		my $id = $self->id;
                 utf8::downgrade($id) if utf8::is_utf8($id);
                 unshift @search_args, ($f_key => $id);
      		 ## end-of-change

                 push @search_args, { order_by => $args->{order_by} }
                     if defined $args->{order_by};
                 return $f_class->search(@search_args);
             } else {
		## blah, blah.... didn't change this so need to cut/paste it.
             }
         };
}

This is a horrible hack.... does anyone have a better fix for this  
utf8 problem?

thanks.

j.
--
Jim Lambert
jlambert at brandeis.edu / AIM: jimlambrt




Begin forwarded message:

> I'm having some issues with using Class::DBI with utf8 data in an  
> oracle database.
>
> I have to make all the columns 'Essential' or everything just hangs  
> when I try to retrieve non-primary key columns.
>
> Also, I can't seem to get has_many relationships to work with this  
> utf8 database.   When I try to retrieve a has_many relationship  
> objects, the query just hangs.
>
> I have noticed, that if I downgrade the utf8 data, then I can use  
> it to retrieve Class::DBI sub-classes.   Unfortunately, there's no  
> way to downgrade the primary key data used internally in Class::DBI  
> to retrieve has_many relationship objects.
>
> Any help would be appreciated.
>
> j.
> --
> Jim Lambert
> jlambert at brandeis.edu / AIM: jimlambrt




More information about the ClassDBI mailing list