Bonus: regexp support for pgsql happily stolen from biblio.
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | 1935300_26.patch | 8.65 KB | chx |
| #24 | 1935300_24.patch | 10.6 KB | chx |
| #17 | drupal-1935300-17.patch | 8.6 KB | dawehner |
| #17 | interdiff.txt | 2.91 KB | dawehner |
| #14 | drupal-1935300-14.patch | 7.63 KB | dawehner |
Comments
Comment #1
dawehnerI'm wondering whether this should be part of dbtng itself.
Comment #2
chx commentedLet's ask the DBTNG boss.
Comment #4
dawehnerI chosed to use a static method() as you maybe shouldn't have a select object for example in the UI,
though this makes it hard for select extenders.
Comment #6
dawehnerMake it really working :)
Comment #7
Crell commentedFalse. Making this method static has no benefit. Don't make it static. Nothing should be static unless it really really has to be, which this does not.
I have no idea what this @todo means, but as above, don't make this static. Then you can leave this out entirely in the abstract base class.
Huh? If we can't support regexes across all of our supported databases, then we can't add them. That means this if-check is meaningless.
Comment #8
dawehnerWell, yeah before it has been checked whether we use mysql, so the patch just had the same structure.
Rewrote the patch to not use a static. As you don't have the query object available when views builds the query,
I needed to fake it.
Added also a test for the filter by regex support.
Comment #9
damien tournoud commentedPlease. Make this a proper
mapConditionOperator()... why would we special case this particular operator?Comment #10
dawehnerOh i like that!
Comment #11
chx commentedI like it too but I think you had a typo here. Also, big kudos to Damien for his wisdom.
Comment #12
chx commentedNah. There was a lot left to be desired in the previous version: SQLite support and the Numeric class. The size of the interdiff is nearly the same as the patch itself so this borders on a ground up rewrite. I kept the test though :)
I also have removed RLIKE completely and used REGEXP because SQLite has special support for that and MySQL works for both (and in fact the documentations treats REGEXP as first class). As it doesnt matter which we use, why not use an operator that 2 out of 3 the core databases have native support for?
Oracle http://docs.oracle.com/cd/B14117_01/server.101/b10759/conditions018.htm
MS SQL is problematic but doable http://msdn.microsoft.com/en-us/library/ee633712(SQL.105).aspx and http://www.codeproject.com/Articles/42764/Regular-Expressions-in-MS-SQL-...
MongoDB has easy native regexp http://docs.mongodb.org/manual/reference/operator/regex/ support.
Comment #13
chx commentedFiled #1937848: Combine uses add_where_expression needlessly as a followup for Combine.
Comment #14
dawehnerOh, that's nice.
Just adapted a bunch of minor issues. This looks now basically ready to go.
Comment #15
berdirYay for removing hacks in favor of better generic database support :)
I assume we document the supported operators somewhere, so we should update that documentation?
So sqlite will use php-based perl-compatible regex syntax and mysql/postgreSQL will use POSIX. Are there any differences between the MySQL and PostgreSQL implementations/syntax? A quick google search pointed me to http://www.regular-expressions.info/refflavors.html, which says POSIX for MySQL and an special version for PostgreSQL that extends POSIX with perl-regex inspired features?
As we can't do anything about it, maybe just document which backend uses which implementation and that it is recommended to limit yourself to POSIX to have a common subset or something like that?
Could there be a security issue when exposing this to the UI? Just asking, probably not :)
Comment #16
damien tournoud commentedThis looks wrong. I assume you meant to quote the pattern, not the string.
In addition, this needs to be made case insensitive (both MySQL and PostgreSQL are).
Comment #17
dawehnerI tried to search for "BETWEEN" and "LIKE" but couldn't find a place in core, so I guess http://drupal.org/node/773090 is the place to update that?
Do have you have a good idea where to document that? We could use the page linked above.
"Administer views" is a restricted permission, so you should trust these people. What is a proper way to take care of that? It seems to be that we could disable this operator to be available in exposed forms, but well, this seems to be not needed.
It seems to be impossible http://stackoverflow.com/questions/14616235/regex-sqlite-case-insensitiv...
What should we do about that, but yeah maybe you have another idea.
Added a test for the quoting.
Comment #18
chx commentedIt's totally possible to make it unconditionally case insensitive you just cant pass in the i flag via the query.
Comment #19
damien tournoud commentedSo, this is still wrong:
We don't want to use
preg_quote()here, because it replaces all the special characters (ie. all the useful characters like*,., etc.).I think what we want is
preg_match('#' . str_replace('#', '\#', $pattern) . '#i', $string).Comment #20
Crell commentedComment #21
Crell commented#17: drupal-1935300-17.patch queued for re-testing.
Comment #23
dawehner.
Comment #24
chx commentedManually re-applied the whole patch as it hopelessly didn't apply any more. I hope I got it right. Made SQLite case insensitive, did #19.
Comment #26
chx commentedOne too many paste pressed.
Comment #27
dawehnerI am perfectly fine with this patch.
Comment #29
chx commented#26: 1935300_26.patch queued for re-testing.
Comment #30
dawehnerJust a bot failure.
Comment #31
catchLooks like good cleanup. I'm a bit shocked we have this feature at all, but since we do no need to hard-code it.
Committed/pushed to 8.x, thanks!
Comment #33
johnchqueThis change is wrong, is breaking the execution query() when you execute $this->{$info[$this->operator]['method']}($field); as the correct method is opRegex and not op_regex.
Comment #34
johnchqueCreated issue for the fixes I commented above. #2650964: Fix the execution of regular expression