mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/10942] Require same data type and do not cast expressions automatically
PHPBB3-10942
This commit is contained in:
parent
0fd02035d8
commit
a8cf926566
6 changed files with 2 additions and 65 deletions
|
@ -286,6 +286,8 @@ class dbal
|
|||
/**
|
||||
* Build a case expression
|
||||
*
|
||||
* Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database!
|
||||
*
|
||||
* @param string $condition The condition which must be true, to use action_true rather then action_else
|
||||
* @param string $action_true SQL expression that is used, if the condition is true
|
||||
* @param string $action_else SQL expression that is used, if the condition is false, optional
|
||||
|
|
|
@ -91,19 +91,6 @@ class dbal_mssql extends dbal
|
|||
return ($this->sql_server_version) ? 'MSSQL<br />' . $this->sql_server_version : 'MSSQL';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_case($condition, $action_true, $action_false = false)
|
||||
{
|
||||
// To ensure, that both expressions have the same type, we cast them to varchar manually
|
||||
$sql_case = 'CASE WHEN ' . $condition;
|
||||
$sql_case .= ' THEN CAST(' . $action_true . ' AS VARCHAR)';
|
||||
$sql_case .= ($action_false !== false) ? ' ELSE CAST(' . $action_false . ' AS VARCHAR)' : '';
|
||||
$sql_case .= ' END';
|
||||
return $sql_case;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -109,19 +109,6 @@ class dbal_mssql_odbc extends dbal
|
|||
return ($this->sql_server_version) ? 'MSSQL (ODBC)<br />' . $this->sql_server_version : 'MSSQL (ODBC)';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_case($condition, $action_true, $action_false = false)
|
||||
{
|
||||
// To ensure, that both expressions have the same type, we cast them to varchar manually
|
||||
$sql_case = 'CASE WHEN ' . $condition;
|
||||
$sql_case .= ' THEN CAST(' . $action_true . ' AS VARCHAR)';
|
||||
$sql_case .= ($action_false !== false) ? ' ELSE CAST(' . $action_false . ' AS VARCHAR)' : '';
|
||||
$sql_case .= ' END';
|
||||
return $sql_case;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -257,19 +257,6 @@ class dbal_mssqlnative extends dbal
|
|||
return ($this->sql_server_version) ? 'MSSQL<br />' . $this->sql_server_version : 'MSSQL';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_case($condition, $action_true, $action_false = false)
|
||||
{
|
||||
// To ensure, that both expressions have the same type, we cast them to varchar manually
|
||||
$sql_case = 'CASE WHEN ' . $condition;
|
||||
$sql_case .= ' THEN CAST(' . $action_true . ' AS VARCHAR)';
|
||||
$sql_case .= ($action_false !== false) ? ' ELSE CAST(' . $action_false . ' AS VARCHAR)' : '';
|
||||
$sql_case .= ' END';
|
||||
return $sql_case;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -89,19 +89,6 @@ class dbal_oracle extends dbal
|
|||
return $this->sql_server_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_case($condition, $action_true, $action_false = false)
|
||||
{
|
||||
// To ensure, that both expressions have the same type, we cast them to clob manually
|
||||
$sql_case = 'CASE WHEN ' . $condition;
|
||||
$sql_case .= ' THEN CAST(' . $action_true . ' AS clob)';
|
||||
$sql_case .= ($action_false !== false) ? ' ELSE CAST(' . $action_false . ' AS clob)' : '';
|
||||
$sql_case .= ' END';
|
||||
return $sql_case;
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Transaction
|
||||
* @access private
|
||||
|
|
|
@ -154,19 +154,6 @@ class dbal_postgres extends dbal
|
|||
return ($raw) ? $this->sql_server_version : 'PostgreSQL ' . $this->sql_server_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_case($condition, $action_true, $action_false = false)
|
||||
{
|
||||
// To ensure, that both expressions have the same type, we cast them to text manually
|
||||
$sql_case = 'CASE WHEN ' . $condition;
|
||||
$sql_case .= ' THEN CAST(' . $action_true . ' AS TEXT)';
|
||||
$sql_case .= ($action_false !== false) ? ' ELSE CAST(' . $action_false . ' AS TEXT)' : '';
|
||||
$sql_case .= ' END';
|
||||
return $sql_case;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue