Problem
When running Drupal with PostgreSQL 9.1 and using the Advanced Link widget and set "start with specified characters" as auto complete suggestion type, after typing a character gives a PDO Exception like this:
PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "REGEXP" LINE 4: WHERE (mr.path REGEXP '^test[^\%]*$') ^: SELECT mr.path AS path FROM {menu_router} mr WHERE (mr.path REGEXP :db_condition_placeholder_0) LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => ^test[^\%]*$ ) in advanced_link_url_load() (line 87 of /var/www/xyz/public_html/sites/all/modules/contrib/advanced_link/advanced_link.module).
Problem: advanced_link.module uses REGEXP as sql condition, but pgsql doesn´t know about REGEXP.
An pgsql equivalent to mySQL REGEXP should be using POSIX Regular Expressions
http://www.postgresql.org/docs/9.1/static/functions-matching.html
So for pgsql it could be ~ instead of REGEXP:
$result = db_select('menu_router', 'mr')
->fields('mr', array('path'))
->condition('mr.path', $condition_menu, '~')
->range(0, 10)->execute();
Proposed resolution
Maybe there should be a database connection type check before and then based on the result using the correct condition sql syntax.
How to get the current db connection type in Drupal 7?
Is there a function or variable?
Comments
Comment #1
DrupalDriven commentedThanx for bug report, in next release module will be compatible with PostgreSQL
Comment #2
Eugene Fidelin commentedImplemented in latest versions of Advanced link module
Comment #4
ziomizar commentedI have the same problem with :
- MySql
- Advanced Link widget
- contains
When i try to search with this string : [e-