From koenc [...] dalicon.com Thu Jul 25 05: | 31:35 2013 |
CC: | "'K. Cuelenaere'" <koenc [...] dalicon.com> |
MIME-Version: | 1.0 |
X-Spam-Status: | No, score=-5.549 tagged_above=-99.9 required=10 tests=[AWL=-1.349, BAYES_50=0.8, RCVD_IN_DNSWL_HI=-5] autolearn=ham |
X-Spam-Flag: | NO |
content-type: | text/plain; charset="utf-8"; format="flowed" |
Message-ID: | <51F0F05F.6070300 [...] dalicon.com> |
X-Virus-Scanned: | Debian amavisd-new at bestpractical.com |
X-Spam-Score: | -5.549 |
Received: | from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 90E6124052B for <cpan-bug+search-queryparser-sql [...] hipster.bestpractical.com>; Thu, 25 Jul 2013 05:31:35 -0400 (EDT) |
Received: | from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vQlPd2LMj1Gd for <cpan-bug+search-queryparser-sql [...] hipster.bestpractical.com>; Thu, 25 Jul 2013 05:31:30 -0400 (EDT) |
Received: | from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 261F92404FC for <bug-search-queryparser-sql [...] rt.cpan.org>; Thu, 25 Jul 2013 05:31:29 -0400 (EDT) |
Received: | (qmail 4242 invoked by alias); 25 Jul 2013 09:31:29 -0000 |
Received: | from fep17.mx.upcmail.net (HELO fep17.mx.upcmail.net) (62.179.121.37) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 25 Jul 2013 02:31:23 -0700 |
Received: | from edge02.upcmail.net ([192.168.13.237]) by viefep17-int.chello.at (InterMail vM.8.01.05.05 201-2260-151-110-20120111) with ESMTP id <20130725093118.CUDO8072.viefep17-int.chello.at [...] edge02.upcmail.net>; Thu, 25 Jul 2013 11:31:18 +0200 |
Received: | from [10.0.1.123] ([95.97.92.196]) by edge02.upcmail.net with edge id 4ZXH1m03c4EBnwF02ZXJj2; Thu, 25 Jul 2013 11:31:18 +0200 |
Delivered-To: | cpan-bug+search-queryparser-sql [...] hipster.bestpractical.com |
Subject: | the dbic output for negations shows problem when combining with other searchs |
User-Agent: | Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 |
Return-Path: | <koenc [...] dalicon.com> |
X-RT-Mail-Extension: | search-queryparser-sql |
X-Original-To: | cpan-bug+search-queryparser-sql [...] hipster.bestpractical.com |
X-Spam-Check-BY: | la.mx.develooper.com |
Date: | Thu, 25 Jul 2013 11:31:11 +0200 |
X-Spam-Level: | |
X-Sourceip: | 95.97.92.196 |
To: | bug-search-queryparser-sql [...] rt.cpan.org |
Content-Transfer-Encoding: | 7bit |
From: | Koen Cuelenaere <koenc [...] dalicon.com> |
X-RT-Original-Encoding: | iso-8859-1 |
X-RT-Interface: | |
Content-Length: | 1642 |
Dear reader,
I'm using search-queryparser-sql v0.08, and I'm using this module
to construct DBIx::Class type of search structures.
This is what I do in my Perl code:
my $qp = Search::QueryParser::SQL->new(
columns => ['table1.column1', 'table1.column2'],
like => 'LIKE',
fuzzify2 => 1,
);
my $query = $qp->parse("$value", 0);
print Dumper $query->dbic;
print Dumper $query->stringify;
When I search for "butter -milk"
This is what I see:
as output:
$VAR1 = [
***'-or'***,
[
'-or',
[
'table1.column1',
{
'LIKE' => '%butter%'
},
'table1.column2',
{
'LIKE' => '%butter%'
}
],
'-and',
[
'table1.column1',
{
'NOT LIKE' => '%milk%'
},
'table1.column2',
{
'NOT LIKE' => '%milk%'
}
]
]
];
$VAR1 = '(table1.column1 LIKE \'%butter%\' OR table1.column2 LIKE
\'%butter%\') ***AND*** (table1.column1 NOT LIKE \'%milk%\' AND
table1.column2 NOT LIKE \'%milk%\')';
I have marked the problem with stars. The DBIx::Class/dbic/orm version
in my opinion shows a bug, as it uses
an "or", while the regular SQL version (second output) shows the correct
"and".
I'll try to work on a fix for it, but you might beat me to it ;)
best regards
Koen Cuelenaere
Dalicon BV