-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing parameters in ProxyResultSetMethod #39
Comments
That's a good idea, but don't forget that the return value gets cached, and If you want to play along at home, here are my reservations: if the user -frew
|
But with_foo on RS works already, that's the thing. sub with_is_manager_assigned {
my ($self, $user) = @_;
return $self->search(
undef,
{ '+columns' => {
is_manager_assigned =>
$self->correlate('map_managers')
->count_rs({ user_id => $user->id })->as_query
},
},
);
} This allows me to: $rs->with_is_manager_assigned($user); But not: $row->is_manager_assigned($user); |
Where does the caching happen at? Is it the DBIC internal caching via |
yeah, it's DBIC internal caching. I see your problem and am not trying to say it doesn't matter, I'm just saying that you can
and then after that on the row you get back do
and get what it would have been for frew, and I'm not sure how to get past that except some kind of crazy serialization of the args smashed into the hash key for {_column_data}... |
Ah, I see. I will poke around internals to see what is possible. But I am sure you are more intimately familiar with them and already know what is possible and what is not :) |
I sorta think that what you want might be better part of either another helper or an extension/option on top of this one. How would you feel about:
? |
Are you thinking of caching the results with serialized key? I'll be honest, the argument is definitely making it look ugly. But if that's the only way :) |
I agree that it's gross and probably perilous. I think maybe a better optiono is to have a NonCachingProxyResultSetMethod that just always hits the db. Obviously it's not as awesome as this is, but it would solve your problem. How do you feel about that? |
Sometimes it is useful to pass a parameter to build a query. E.g.
with_user_roles($role)
. However, it is only possible to do with a ResultSet, but if calling on a row, the parameters are omitted.See:
https://github.com/frioux/DBIx-Class-Helpers/blob/master/lib/DBIx/Class/Helper/Row/ProxyResultSetMethod.pm#L35
I propose this should be
->$rs_method(@_)
(but shift the first value first, of course).What do you think?
The text was updated successfully, but these errors were encountered: