From cdf28e6fd6aa87b8e0302bcc88505f378a38968d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 22 Sep 2010 03:22:20 +0000 Subject: - Patch #910388 by mikl: installation fails on PostgreSQL 8.4: Invalid escape sequence. --- includes/database/pgsql/database.inc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'includes/database') diff --git a/includes/database/pgsql/database.inc b/includes/database/pgsql/database.inc index ec3acbb22..e6e6eef96 100644 --- a/includes/database/pgsql/database.inc +++ b/includes/database/pgsql/database.inc @@ -135,13 +135,18 @@ class DatabaseConnection_pgsql extends DatabaseConnection { } public function mapConditionOperator($operator) { - static $specials = array( - // In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE - // statements, we need to use ILIKE instead. Use backslash for escaping - // wildcard characters. - 'LIKE' => array('operator' => 'ILIKE', 'postfix' => " ESCAPE '\\\\'"), - 'NOT LIKE' => array('operator' => 'NOT ILIKE', 'postfix' => " ESCAPE '\\\\'"), - ); + static $specials; + + // Function calls not allowed in static declarations, thus this method. + if (!isset($specials)) { + $specials = array( + // In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE + // statements, we need to use ILIKE instead. Use backslash for escaping + // wildcard characters. + 'LIKE' => array('operator' => 'ILIKE', 'postfix' => ' ESCAPE ' . $this->quote("\\")), + 'NOT LIKE' => array('operator' => 'NOT ILIKE', 'postfix' => ' ESCAPE ' . $this->quote("\\")), + ); + } return isset($specials[$operator]) ? $specials[$operator] : NULL; } -- cgit v1.2.3