Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removing dead code from DboSource::fields()

Updating fields() to use implode, so complex virtual fields are better handled.  Fixes #1079
  • Loading branch information...
commit d113d7d6126d063e2401923e49f8befd5d4e22c3 1 parent 738d92c
@markstory markstory authored
View
12 cake/libs/model/datasources/dbo_source.php
@@ -2023,18 +2023,8 @@ function fields(&$model, $alias = null, $fields = array(), $quote = true) {
if ($comma === false) {
$build = explode('.', $fields[$i]);
if (!Set::numeric($build)) {
- $fields[$i] = $this->name($build[0] . '.' . $build[1]);
+ $fields[$i] = $this->name(implode('.', $build));
}
- $comma = String::tokenize($fields[$i]);
- foreach ($comma as $string) {
- if (preg_match('/^[0-9]+\.[0-9]+$/', $string)) {
- $value[] = $string;
- } else {
- $build = explode('.', $string);
- $value[] = $this->name(trim($build[0]) . '.' . trim($build[1]));
- }
- }
- $fields[$i] = implode(', ', $value);
}
}
$fields[$i] = $prepend . $fields[$i];
View
18 cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -4510,6 +4510,24 @@ function testFieldsWithComplexVirtualFields() {
}
/**
+ * test reading virtual fields containing newlines when recursive > 0
+ *
+ * @return void
+ */
+ function testReadVirtualFieldsWithNewLines() {
+ $Article =& new Article();
+ $Article->recursive = 1;
+ $Article->virtualFields = array(
+ 'test' => '
+ User.id + User.id
+ '
+ );
+ $result = $this->db->fields($Article, null, array());
+ $result = $this->db->fields($Article, $Article->alias, $result);
+ $this->assertPattern('/[`\"]User[`\"]\.[`\"]id[`\"] \+ [`\"]User[`\"]\.[`\"]id[`\"]/', $result[7]);
+ }
+
+/**
* test group to generate GROUP BY statements on virtual fields
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.