Skip to content

Commit f719f5e

Browse files
committed
Don't remove characters from expression
Signed-off-by: Maximilian Krög <maximilian.kroeg@geocept.com>
1 parent bea4b68 commit f719f5e

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

libraries/classes/Table/ColumnsDefinition.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
use function in_array;
2525
use function intval;
2626
use function is_array;
27+
use function mb_strlen;
2728
use function mb_strtoupper;
29+
use function mb_substr;
2830
use function preg_quote;
2931
use function preg_replace;
3032
use function rtrim;
@@ -514,8 +516,6 @@ public static function decorateColumnMetaDefault(array $columnMeta): array
514516
// Could be null or empty string here
515517
if ($columnMeta['Default'] === null) {
516518
$metaDefault['DefaultType'] = $columnMeta['Null'] === 'YES' ? 'NULL' : 'NONE';
517-
} else {
518-
$columnMeta['DefaultValue'] = $columnMeta['Default'];
519519
}
520520

521521
break;
@@ -531,8 +531,16 @@ public static function decorateColumnMetaDefault(array $columnMeta): array
531531
break;
532532
default:
533533
if (substr((string) $columnMeta['Type'], -4) === 'text') {
534-
$textDefault = substr($columnMeta['Default'], 1, -1);
535-
$metaDefault['DefaultValue'] = stripcslashes($textDefault);
534+
if (
535+
mb_strlen($columnMeta['Default']) >= 2 &&
536+
mb_substr($columnMeta['Default'], 0, 1) === "'" &&
537+
mb_substr($columnMeta['Default'], -1) === "'"
538+
) {
539+
$textDefault = substr($columnMeta['Default'], 1, -1);
540+
$metaDefault['DefaultValue'] = stripcslashes($textDefault);
541+
} else {
542+
$metaDefault['DefaultValue'] = $columnMeta['Default'];
543+
}
536544
} else {
537545
$metaDefault['DefaultValue'] = $columnMeta['Default'];
538546
}

0 commit comments

Comments
 (0)