mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Correcting column quoting for custom-aliased fields, fixes #4228
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6543 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
be09e5a90d
commit
8fc104b44b
2 changed files with 11 additions and 0 deletions
|
@ -360,6 +360,9 @@ class DboSource extends DataSource {
|
|||
}
|
||||
$data[$i] = $this->startQuote . str_replace('.', $this->endQuote . '.' . $this->startQuote, $data[$i]) . $this->endQuote;
|
||||
$data[$i] = str_replace($this->startQuote . $this->startQuote, $this->startQuote, $data[$i]);
|
||||
if (strpos($data[$i], ' AS ')) {
|
||||
$data[$i] = str_replace(' AS ', $this->endQuote . ' AS ' . $this->startQuote, $data[$i]);
|
||||
}
|
||||
|
||||
if (!empty($this->endQuote) && $this->endQuote == $this->startQuote) {
|
||||
if (substr_count($data[$i], $this->endQuote) % 2 == 1) {
|
||||
|
|
|
@ -1821,6 +1821,14 @@ class DboSourceTest extends CakeTestCase {
|
|||
$result = $this->db->fields($this->Model, null, array('MAX(Model.field) As Max'));
|
||||
$expected = array('MAX(`Model`.`field`) As Max');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->db->fields($this->Model, null, array('Model.field AS AnotherName'));
|
||||
$expected = array('`Model`.`field` AS `AnotherName`');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->db->fields($this->Model, null, array('field AS AnotherName'));
|
||||
$expected = array('`TestModel`.`field` AS `AnotherName`');
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testMergeAssociations() {
|
||||
|
|
Loading…
Add table
Reference in a new issue