* Api: truncate varchar for all DB types now, as MariaDB 10.3 also errors on to big content

This commit is contained in:
Ralf Becker 2018-12-09 13:52:31 +01:00
parent 22bd2b25f6
commit 079852bdce

View File

@ -1483,9 +1483,8 @@ class Db
{ {
$value = implode($glue,$value); $value = implode($glue,$value);
} }
// only truncate string if length given and <= 255 // truncate to long strings for varchar(X) columns as PostgreSQL and newer MySQL/MariaDB given an error otherwise
// to not unnecessary truncate varchar(>255) as PostgreSQL uses text anyway and MySQL truncates itself silently (unless strict mode!) if (!is_null($length) && mb_strlen($value) > $length)
if (!is_null($length) && $length <= 255 && mb_strlen($value) > $length)
{ {
$value = mb_substr($value, 0, $length); $value = mb_substr($value, 0, $length);
} }