Hello,
I am trying to create a filter criteria for a view using regular expression but it seams that it is not working.
For example I want to check if Nid is odd or even number. To achieve that I can use regular expression '[02468]$' to check if Nid ends with even number.
If I select from DB following statement it returns 1 - so it is correct
SELECT 26 REGEXP '[02468]$'
But if I create a filter criteria as a 'Regular expression" and pass value '[02468]$' (I have tried with and without quotes), then view does not return any value.
In some views I get following error
SQLSTATE[42000]: Syntax error or access violation: 1139 Got error 'empty (sub)expression' from regexp
Could you please explain what I am doing wrong?
Or is this really a bug?
I am using
Drupal 7.17 with XAMPP v3.1.0
DB server: 5.5.27 - MySQL Community Server (GPL)
Web server: Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7
phpMyAdmin: 3.5.2.2
Thanks In Advance,
Alvis
Comments
Comment #1
alviSic CreditAttribution: alviSic commentedComment #2
ericaack CreditAttribution: ericaack commentedSame problem.
Comment #3
dawehnerCould you please post the full query generated by views? I could imagine that this gives some needed context.
Comment #4
monish_deb CreditAttribution: monish_deb commentedCurrently the resultant query is appending empty string which is a mere syntax error, see the where clause below
whereas
WHERE (( (node.nid RLIKE '[02468]$') ))
resolves the issueComment #5
monish_deb CreditAttribution: monish_deb commentedThis is the required changes
Also the same for "views/handlers/views_handler_filter_string.inc" .
Comment #6
dawehner#1514162: Regular expression filters on numeric fields produce invalid SQL
Comment #7
apaderno