mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Postgres datasource support regular expression operators.
This commit is contained in:
parent
9f25da49ef
commit
84725993e5
2 changed files with 19 additions and 0 deletions
|
@ -94,6 +94,13 @@ class Postgres extends DboSource {
|
|||
*/
|
||||
protected $_sequenceMap = array();
|
||||
|
||||
/**
|
||||
* The set of valid SQL operations usable in a WHERE statement
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', '~', '~*', '!~', '!~*', 'similar to');
|
||||
|
||||
/**
|
||||
* Connects to the database using options in the given configuration array.
|
||||
*
|
||||
|
|
|
@ -486,6 +486,18 @@ class PostgresTest extends CakeTestCase {
|
|||
$this->assertEquals($data, $result['BinaryTest']['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests passing PostgreSQL regular expression operators when building queries
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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 "name" !~* \'[a-z_]+\'', $this->Dbo->conditions(array('name !~*' => '[a-z_]+')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the syntax of generated schema indexes
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue