DBIx::SearchBuilder - Limit by multiple fields using OR clause

Hello,

I found DBIx::Searchbuilder is using the ENTRYAGGREGATOR ‘OR’ only when
limiting to the same field multiple times. Let’s say if I want to Limit the
Users table by Name or RealName a can’t make it to use OR clause. It still uses
AND and it seems to me it cannot be changed without changing the
DBIx::SearchBuilder.

For example this code:

my $UsersObj = new RT::Users($self->CurrentUser);
$UsersObj->Limit(
FIELD => ‘Name’,
VALUE => ‘something’,
OPERATOR => ‘LIKE’
);

$UsersObj->Limit(
FIELD => ‘RealName’,
VALUE => ‘something’,
OPERATOR => ‘LIKE’,
ENTRYAGGREGATOR => ‘OR’
);

produces this query:

SELECT * FROM Users main WHERE ( ((main.Disabled = 0)) AND ((main.Name LIKE
‘%something%’)) AND ((main.RealName LIKE ‘%SOMETHING%’)) )

but I want it this way:

SELECT * FROM Users main WHERE ( ((main.Disabled = 0)) AND ((main.Name LIKE
‘%something%’) OR (main.RealName LIKE ‘%SOMETHING%’)) )

Can this be achieved via some documented way?

Greets,

Miroslav Laus, DiS
Senior technician, Operations Management Center
Karneval Media s.r.o.
U svobodarny 5/1500
190 00 Praha 9
Czech republic
tel: +420 2 8408 5354
fax: +420 2 8408 5817
mob: +420 724 608 011
e-mail: laus@karneval.cz
http://www.karneval.cz

Hello,

I found DBIx::Searchbuilder is using the ENTRYAGGREGATOR ‘OR’ only when
limiting to the same field multiple times. Let’s say if I want to Limit the
Users table by Name or RealName a can’t make it to use OR clause. It still uses
AND and it seems to me it cannot be changed without changing the
DBIx::SearchBuilder.

use SUBCLAUSE => ‘mysubclause’ in your Limit statements to get both
entries into the same subclause.

-jesse

Thanks Jesste, it works like a charm.

MiroslavOn 23. Sep v 02:59, Jesse Vincent wrote:

On Thu, Sep 23, 2004 at 08:53:41AM +0200, Miroslav Laus wrote:

Hello,

I found DBIx::Searchbuilder is using the ENTRYAGGREGATOR ‘OR’ only when
limiting to the same field multiple times. Let’s say if I want to Limit the
Users table by Name or RealName a can’t make it to use OR clause. It still uses
AND and it seems to me it cannot be changed without changing the
DBIx::SearchBuilder.

use SUBCLAUSE => ‘mysubclause’ in your Limit statements to get both
entries into the same subclause.

-jesse

For example this code:

my $UsersObj = new RT::Users($self->CurrentUser);
$UsersObj->Limit(
FIELD => ‘Name’,
VALUE => ‘something’,
OPERATOR => ‘LIKE’
);

$UsersObj->Limit(
FIELD => ‘RealName’,
VALUE => ‘something’,
OPERATOR => ‘LIKE’,
ENTRYAGGREGATOR => ‘OR’
);

produces this query:

SELECT * FROM Users main WHERE ( ((main.Disabled = 0)) AND ((main.Name LIKE
‘%something%’)) AND ((main.RealName LIKE ‘%SOMETHING%’)) )

but I want it this way:

SELECT * FROM Users main WHERE ( ((main.Disabled = 0)) AND ((main.Name LIKE
‘%something%’) OR (main.RealName LIKE ‘%SOMETHING%’)) )

Can this be achieved via some documented way?


Greets,

Miroslav Laus, DiS
Senior technician, Operations Management Center

Karneval Media s.r.o.
U svobodarny 5/1500
190 00 Praha 9
Czech republic
tel: +420 2 8408 5354
fax: +420 2 8408 5817
mob: +420 724 608 011
e-mail: laus@karneval.cz
http://www.karneval.cz


Rt-devel mailing list
Rt-devel@lists.bestpractical.com
The rt-devel Archives