mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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
This commit is contained in:
parent
0841c04351
commit
2f616a9e0c
2 changed files with 5 additions and 1 deletions
|
@ -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 @@ class PostgresTest extends CakeTestCase {
|
|||
$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))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue