Make MySQL collation syntax default

Overwrite customVarsJoinTemplate for Postgres and Oracle.

refs #8696
This commit is contained in:
Marius Hein 2015-05-21 16:09:03 +02:00
parent e8e3b940af
commit 7c04664888
1 changed files with 5 additions and 5 deletions

View File

@ -96,7 +96,7 @@ abstract class IdoQuery extends DbQuery
* @var string * @var string
*/ */
private $customVarsJoinTemplate = private $customVarsJoinTemplate =
'%1$s = %2$s.object_id AND %2$s.varname = %3$s'; '%1$s = %2$s.object_id AND %2$s.varname = %3$s COLLATE latin1_general_ci';
/** /**
* An array with all 'virtual' tables that are already joined * An array with all 'virtual' tables that are already joined
@ -363,6 +363,8 @@ abstract class IdoQuery extends DbQuery
$this->object_id = $this->host_id = $this->service_id $this->object_id = $this->host_id = $this->service_id
= $this->hostgroup_id = $this->servicegroup_id = $this->hostgroup_id = $this->servicegroup_id
= $this->contact_id = $this->contactgroup_id = 'id'; = $this->contact_id = $this->contactgroup_id = 'id';
$this->customVarsJoinTemplate =
'%1$s = %2$s.object_id AND LOWER(%2$s.varname) = %3$s';
foreach ($this->columnMap as &$columns) { foreach ($this->columnMap as &$columns) {
foreach ($columns as &$value) { foreach ($columns as &$value) {
$value = preg_replace('/UNIX_TIMESTAMP/', 'localts2unixts', $value); $value = preg_replace('/UNIX_TIMESTAMP/', 'localts2unixts', $value);
@ -376,6 +378,8 @@ abstract class IdoQuery extends DbQuery
*/ */
private function initializeForPostgres() private function initializeForPostgres()
{ {
$this->customVarsJoinTemplate =
'%1$s = %2$s.object_id AND LOWER(%2$s.varname) = %3$s';
foreach ($this->columnMap as $table => & $columns) { foreach ($this->columnMap as $table => & $columns) {
foreach ($columns as $key => & $value) { foreach ($columns as $key => & $value) {
$value = preg_replace('/ COLLATE .+$/', '', $value, -1, $count); $value = preg_replace('/ COLLATE .+$/', '', $value, -1, $count);
@ -410,10 +414,6 @@ abstract class IdoQuery extends DbQuery
$this->initializeForOracle(); $this->initializeForOracle();
} elseif ($dbType === 'pgsql') { } elseif ($dbType === 'pgsql') {
$this->initializeForPostgres(); $this->initializeForPostgres();
$this->customVarsJoinTemplate =
'%1$s = %2$s.object_id AND LOWER(%2$s.varname) = %3$s';
} elseif ($dbType === 'mysql') {
$this->customVarsJoinTemplate .= ' COLLATE latin1_general_ci';
} }
$this->dbSelect(); $this->dbSelect();
$this->select->columns($this->columns); $this->select->columns($this->columns);