[Rt-devel] RT::Record::LoadByCols weirdness (bug?)

Dmitri Tikhonov dtikhonov at vonage.com
Tue Apr 25 10:42:54 EDT 2006


Enclosed patch seems to fix the problem.  Could someone please review
it?

  - Dmitri.

On Tue, 2006-04-25 at 10:25 -0400, Dmitri Tikhonov wrote:
> Dear Fellow RTers,
> 
> RT::Record overrides DBIx::SearchBuilder::Record::LoadByCols.  In
> particular, its version of the method contains the following code:
> 
>   my ($op, $val, $func);
>   ($key, $op, $val, $func) =
>      $self->_Handle->_MakeClauseCaseInsensitive($key, '=',
> $hash{$key});
>   $newhash{$key}->{operator} = $op;
>   $newhash{$key}->{value} = $val;
>   $newhash{$key}->{function} = $func;
> 
> Of particular concern is the substitution of user-provided operator
> with
> '='.  I would like to filter some tables based on what a value is
> *not*
> equal to ('!=').  Playing with the code above (replacing '=' with '!
> =')
> produced several screens worth of exceptions which I cannot makes
> heads
> and tails of.
> 
> Is this an intrinsic limitation of RT::Record or should this bug be
> fixed?
> 
> Setup:
>   DBIx::SearchBuilder 1.43
>   RT 3.4.5
> 
> Thanks,
> 
>   - Dmitri.
> 
> 
> _______________________________________________
> List info:
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
> 
> Best Practical is hiring! Come hack Perl for us:
> http://bestpractical.com/about/jobs.html
> 
> 
-------------- next part --------------
--- Record.pm.orig	2006-04-25 10:40:57.000000000 -0400
+++ Record.pm	2006-04-25 10:40:53.000000000 -0400
@@ -378,7 +378,14 @@
             }
             else {
                 my ($op, $val, $func);
-                ($key, $op, $val, $func) = $self->_Handle->_MakeClauseCaseInsensitive($key, '=', $hash{$key});
+                if ('HASH' eq ref($hash{$key}) &&
+                    exists($hash{$key}{operator}))
+                {
+                    $op = $hash{$key}{operator};
+                } else {
+                    $op = '=';
+                }
+                ($key, $op, $val, $func) = $self->_Handle->_MakeClauseCaseInsensitive($key, $op, $hash{$key});
                 $newhash{$key}->{operator} = $op;
                 $newhash{$key}->{value} = $val;
                 $newhash{$key}->{function} = $func;


More information about the Rt-devel mailing list