CC: | "'K. Cuelenaere'" <koenc [...] dalicon.com> |
Subject: | the dbic output for negations shows problem when combining with other searchs |
Date: | Thu, 25 Jul 2013 11:31:11 +0200 |
To: | bug-search-queryparser-sql [...] rt.cpan.org |
From: | Koen Cuelenaere <koenc [...] dalicon.com> |
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