Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix `data\source\Database::fields()` with empty alias. #734

Merged
merged 1 commit into from

2 participants

Simon JAILLET Nate Abele
Simon JAILLET
Collaborator

No description provided.

Nate Abele nateabele merged commit 38084ac into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 12, 2012
  1. Simon JAILLET
This page is out of date. Refresh to see the latest.
4 data/source/Database.php
View
@@ -962,8 +962,10 @@ protected function _fieldsQuote($alias, $field) {
list($aliasname, $fieldname) = $this->_splitFieldname($aliasing[0]);
$alias = $aliasname ? : $alias;
return "{$open}{$alias}{$close}.{$open}{$fieldname}{$close} as {$aliasing[1]}";
- } else {
+ } elseif ($alias) {
return "{$open}{$alias}{$close}.{$open}{$field}{$close}";
+ } else {
+ return "{$open}{$field}{$close}";
}
}
7 tests/cases/data/source/DatabaseTest.php
View
@@ -875,6 +875,13 @@ public function testFields() {
$this->assertEqual($expected, $result);
}
+ public function testFieldsWithEmptyAlias() {
+ $query = new Query();
+ $result = $this->db->fields(array('id', 'name', 'created'), $query);
+ $expected = '{id}, {name}, {created}';
+ $this->assertEqual($expected, $result);
+ }
+
public function testRawConditions() {
$query = new Query(array('type' => 'read', 'model' => $this->_model, 'conditions' => null));
$this->assertFalse($this->db->conditions(5, $query));
Something went wrong with that request. Please try again.