Merge pull request #10318 from annando/issue-9926

Separate the char from the binary handling
This commit is contained in:
Hypolite Petovan 2021-05-25 06:05:35 -04:00 committed by GitHub
commit a98a614f40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -242,8 +242,10 @@ class DBStructure
foreach ($fieldnames as $field) {
if (isset($data[$field])) {
// Limit the length of varchar, varbinary, char and binrary fields
if (is_string($data[$field]) && preg_match("/[char|binary]\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
if (is_string($data[$field]) && preg_match("/char\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
$data[$field] = mb_substr($data[$field], 0, $result[1]);
} elseif (is_string($data[$field]) && preg_match("/binary\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
$data[$field] = substr($data[$field], 0, $result[1]);
}
$fields[$field] = $data[$field];
}