Skip to content
Permalink
Browse files

Fix greedy regex operators in Postgres driver.

`*` is greedy in regex, and needs to be escaped so that SQL operators
don't cause invalid SQL conditions to be created.

Refs #6877
  • Loading branch information...
markstory committed Jun 25, 2015
1 parent 0841c04 commit 2f616a9e0cdf1cba7ff657a232e7c5452af44091
@@ -98,7 +98,7 @@ class Postgres extends DboSource {
*
* @var array
*/
protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', '~', '~*', '!~', '!~*', 'similar to');
protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', '~', '~\*', '\!~', '\!~\*', 'similar to');
/**
* Connects to the database using options in the given configuration array.
@@ -490,6 +490,10 @@ public function testRegexpOperatorConditionsParsing() {
$this->assertSame(' WHERE "name" ~* \'[a-z_]+\'', $this->Dbo->conditions(array('name ~*' => '[a-z_]+')));
$this->assertSame(' WHERE "name" !~ \'[a-z_]+\'', $this->Dbo->conditions(array('name !~' => '[a-z_]+')));
$this->assertSame(' WHERE "name" !~* \'[a-z_]+\'', $this->Dbo->conditions(array('name !~*' => '[a-z_]+')));
$this->assertSame(
' WHERE EXTRACT( \'YEAR\' FROM "User"."birthday" ) = 2015',
$this->Dbo->conditions(array('EXTRACT( \'YEAR\' FROM User.birthday )' => 2015))
);
}
/**

0 comments on commit 2f616a9

Please sign in to comment.
You can’t perform that action at this time.