mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Applying patch from 'farhadi' correcting regular expression when using magic findBy and fields that contain findBy in them. Fixes #6138
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8057 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
779b367d3b
commit
2a139b171c
2 changed files with 9 additions and 2 deletions
|
@ -225,10 +225,10 @@ class DboSource extends DataSource {
|
||||||
|
|
||||||
if (strpos(strtolower($args[0]), 'findby') === 0) {
|
if (strpos(strtolower($args[0]), 'findby') === 0) {
|
||||||
$all = false;
|
$all = false;
|
||||||
$field = Inflector::underscore(preg_replace('/findBy/i', '', $args[0]));
|
$field = Inflector::underscore(preg_replace('/^findBy/i', '', $args[0]));
|
||||||
} else {
|
} else {
|
||||||
$all = true;
|
$all = true;
|
||||||
$field = Inflector::underscore(preg_replace('/findAllBy/i', '', $args[0]));
|
$field = Inflector::underscore(preg_replace('/^findAllBy/i', '', $args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$or = (strpos($field, '_or_') !== false);
|
$or = (strpos($field, '_or_') !== false);
|
||||||
|
|
|
@ -3107,6 +3107,13 @@ class DboSourceTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->testDb->query('findByFindBy', array('value'), $this->Model);
|
||||||
|
$expected = array('first', array(
|
||||||
|
'conditions' => array('TestModel.find_by' => 'value'),
|
||||||
|
'fields' => null, 'order' => null, 'recursive' => null
|
||||||
|
));
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->testDb->query('findAllByFieldName', array('value'), $this->Model);
|
$result = $this->testDb->query('findAllByFieldName', array('value'), $this->Model);
|
||||||
$expected = array('all', array(
|
$expected = array('all', array(
|
||||||
'conditions' => array('TestModel.field_name' => 'value'),
|
'conditions' => array('TestModel.field_name' => 'value'),
|
||||||
|
|
Loading…
Add table
Reference in a new issue