only truncate string if length given and <= 255, to not unnecessary truncate varchar(>255) as PostgreSQL uses text anyway and MySQL truncates itself silently (unless strict mode!)

This commit is contained in:
Ralf Becker 2012-08-13 14:43:24 +00:00
parent 3b9f7b3d6d
commit 28354db5d5

View File

@ -1463,7 +1463,9 @@ class egw_db
{
$value = implode($glue,$value);
}
if (!is_null($length) && strlen($value) > $length)
// only truncate string if length given and <= 255
// to not unnecessary truncate varchar(>255) as PostgreSQL uses text anyway and MySQL truncates itself silently (unless strict mode!)
if (!is_null($length) && $length <= 255 && strlen($value) > $length)
{
$value = substr($value,0,$length);
}