Skip to content
Snippets Groups Projects
Commit a9f9dba9 authored by jaapjansma's avatar jaapjansma
Browse files

Fixed issue with custom fields with the same name as an entity field.

parent 054c3d24
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
# Version 1.14.1
* Fixed issue with shoreditch theme #49
* Fixed issue with custom fields with the same name as an entity field.
# Version 1.14.0
......
......@@ -35,7 +35,7 @@ class CustomFieldSpecification extends FieldSpecification {
$this->customFieldTitle = $field['label'];
$options = \CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $this->customFieldId, array(), 'search');
parent::__construct($field['column_name'], $field['data_type'], $custom_group_title. ': '.$this->customFieldTitle, $options, $alias);
parent::__construct($alias, $field['data_type'], $custom_group_title. ': '.$this->customFieldTitle, $options, $alias);
}
......@@ -60,4 +60,11 @@ class CustomFieldSpecification extends FieldSpecification {
return true;
}
/**
* @return String
*/
public function getName() {
return $this->customFieldColumnName;
}
}
......@@ -84,12 +84,12 @@ class FieldSpecification implements SqlFieldSpecification {
public function getSqlSelectStatement($table_alias) {
if ($this->sqlValueFormatFunction) {
if (stripos($this->sqlValueFormatFunction, '%1') !== false && stripos($this->sqlValueFormatFunction, '%2') !== false) {
return "(".str_replace(['%1', '%2'], [$table_alias, $this->name], $this->sqlValueFormatFunction). ") AS `{$this->alias}`";
return "(".str_replace(['%1', '%2'], [$table_alias, $this->getName()], $this->sqlValueFormatFunction). ") AS `{$this->alias}`";
} else {
return "{$this->sqlValueFormatFunction} (`{$table_alias}`.`{$this->name}`) AS `{$this->alias}`";
return "{$this->sqlValueFormatFunction} (`{$table_alias}`.`{$this->getName()}`) AS `{$this->alias}`";
}
}
return "`{$table_alias}`.`{$this->name}` AS `{$this->alias}`";
return "`{$table_alias}`.`{$this->getName()}` AS `{$this->alias}`";
}
/**
......@@ -101,9 +101,9 @@ class FieldSpecification implements SqlFieldSpecification {
*/
public function getSqlColumnName($table_alias) {
if ($this->sqlValueFormatFunction) {
return "{$this->sqlValueFormatFunction} (`{$table_alias}`.`{$this->name}`)";
return "{$this->sqlValueFormatFunction} (`{$table_alias}`.`{$this->getName()}`)";
}
return "`{$table_alias}`.`{$this->name}`";
return "`{$table_alias}`.`{$this->getName()}`";
}
/**
......@@ -117,12 +117,19 @@ class FieldSpecification implements SqlFieldSpecification {
public function getSqlGroupByStatement($table_alias) {
if ($this->sqlValueFormatFunction) {
if (stripos($this->sqlValueFormatFunction, '%1') >= 0 && stripos($this->sqlValueFormatFunction, '%2') >= 0) {
return "(".str_replace(['%1', '%2'], [$table_alias, $this->name], $this->sqlValueFormatFunction). ")";
return "(".str_replace(['%1', '%2'], [$table_alias, $this->getName()], $this->sqlValueFormatFunction). ")";
} else {
return "{$this->sqlValueFormatFunction} (`{$table_alias}`.`{$this->name}`)";
return "{$this->sqlValueFormatFunction} (`{$table_alias}`.`{$this->getName()}`)";
}
}
return "`{$table_alias}`.`{$this->name}`";
return "`{$table_alias}`.`{$this->getName()}`";
}
/**
* @return String
*/
public function getName() {
return $this->name;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment