[Dbix-class] question about documentation for ResultSource and resolve_prefetch method
John Napiorkowski
jjn1056 at yahoo.com
Wed Oct 11 20:45:21 CEST 2006
Hi,
Some of the examples in the POD for ResultSource use a
method called "->source", in particular for the
documentation for the ->resolve_prefetch method.
However this method returns a 'not found' type error.
When I change "->source" to "->result_source" it seems
to fix the trouble. Is this a typo or older version
of the method in the POD?
I also seem to get values from resolve_prefetch that
is a bit different than the documentation suggestions.
Here's how I'm using it:
my $rs = $schema->resultset('Member');
my $src = $rs->->result_source;
my @prefetch = $src->resolve_prefetch(qw/address/);
The relationship is a one to one on the Member schema
and address. From the documentation I would expect
@prefetch to have a list of the columns in the Address
table with the relationship name prepended:
@prefetch == (
"address.street",
"address.city",
[etc]
);
But what I get is:
@prefetch == (
["address.street", "address.street"],
["address.city", "address.city"],
[etc]
);
I'm guessing this have been changed since the docs
where last updated. Or I could just be using it
incorrectly. If anyone knows how this works now I
would be happen to submit a patch to the docs for it.
The goal I have for this is a componant I am writing
to let my users do a 'fuzzy' type search across all
text type columns in a table and in all it's related
tables. So the SQL that I'm trying to make would be
something like:
(Assume a one to one between member and address)
select member.name, member.nickname, address.city,
address.street from member, address where
member.member_id=address.member_id and (member.name
LIKE %?% or member.nickname LIKE %?% or address.city
LIKE %?% or address.street LIKE %?%);
I'd rather make a view for this but on this project
the client refuses to let me create additional tables
or views. Since I have to write queries like this for
about 20 tables I am trying to write a generic
component for it.
Thanks!
John
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Dbix-class
mailing list