[Rt-devel] DBIx::SearchBuilder - Limit by multiple fields using OR clause

Miroslav Laus laus at karneval.cz
Thu Sep 23 02:53:41 EDT 2004


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 at karneval.cz
http://www.karneval.cz



More information about the Rt-devel mailing list