mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
fix SQL error in update from 14.2 and before for newer MariaDB/MySQL
they no longer silently cut of too long content for varchar columns
This commit is contained in:
parent
34efaaa274
commit
cf4301a023
@ -696,6 +696,13 @@ class Schema
|
|||||||
{
|
{
|
||||||
$value = $name;
|
$value = $name;
|
||||||
|
|
||||||
|
// varchar or ascii column shortened, use substring to avoid error if current content is to long
|
||||||
|
if(in_array($old_table_def['fd'][$name]['type'], array('varchar', 'ascii')) &&
|
||||||
|
in_array($data['type'], array('varchar', 'ascii')) &&
|
||||||
|
$old_table_def['fd'][$name]['precision'] > $data['precision'])
|
||||||
|
{
|
||||||
|
$value = "SUBSTRING($value FROM 1 FOR ".(int)$data['precision'].')';
|
||||||
|
}
|
||||||
if ($this->sType == 'pgsql') // some postgres specific code
|
if ($this->sType == 'pgsql') // some postgres specific code
|
||||||
{
|
{
|
||||||
// this is eg. necessary to change a varchar into an int column under postgres
|
// this is eg. necessary to change a varchar into an int column under postgres
|
||||||
@ -709,13 +716,6 @@ class Schema
|
|||||||
{
|
{
|
||||||
$value = "ENCODE($value,'escape')";
|
$value = "ENCODE($value,'escape')";
|
||||||
}
|
}
|
||||||
// varchar or ascii column shortened, use substring to avoid error if current content is to long
|
|
||||||
elseif(in_array($old_table_def['fd'][$name]['type'], array('varchar', 'ascii')) &&
|
|
||||||
in_array($data['type'], array('varchar', 'ascii')) &&
|
|
||||||
$old_table_def['fd'][$name]['precision'] > $data['precision'])
|
|
||||||
{
|
|
||||||
$value = "SUBSTRING($value FROM 1 FOR ".(int)$data['precision'].')';
|
|
||||||
}
|
|
||||||
// cast everything which is a different type
|
// cast everything which is a different type
|
||||||
elseif($old_table_def['fd'][$name]['type'] != $data['type'] && ($type_translated = $this->TranslateType($data['type'])))
|
elseif($old_table_def['fd'][$name]['type'] != $data['type'] && ($type_translated = $this->TranslateType($data['type'])))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user