RT::Record::LoadByCols weirdness (bug?)

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.

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:
The rt-devel Archives

Best Practical is hiring! Come hack Perl for us:
Careers — Best Practical Solutions

rt-record.patch.txt (827 Bytes)

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 (‘!=’).

That strongly suggests that you want a collection, not a record. Can you
explain what you’re doing in more detail?

That strongly suggests that you want a collection, not a record.

Possible :-). It’s only been several days that I’m playing with RT.
However, that does not mean that RT::Record interface is not broken.

Can you explain what you’re doing in more detail?

I added a column into one of the tables. When getting a record, I want
loading to fail if that field is set to some value. I could use a
search, but that gives me incorrect semantics – since I am using ‘id’ I
know there’s only one record (or none).

  • Dmitri.

That strongly suggests that you want a collection, not a record.

Possible :-). It’s only been several days that I’m playing with RT.
However, that does not mean that RT::Record interface is not broken.

Can you explain what you’re doing in more detail?

I added a column into one of the tables. When getting a record, I want
loading to fail if that field is set to some value. I could use a
search, but that gives me incorrect semantics – since I am using ‘id’ I
know there’s only one record (or none).

Those semantics aren’t the way any of the other code works. It’s not
Wrong, just different and unexpected. You’re trying to bend the API in a
way it’s not previously been flexed. (That also lets you walk around
acls in a way that might not be immediately obvious. you can use it to
probe records…)