2424use function in_array ;
2525use function intval ;
2626use function is_array ;
27+ use function mb_strlen ;
2728use function mb_strtoupper ;
2829use function preg_quote ;
2930use function preg_replace ;
3031use function rtrim ;
32+ use function str_ends_with ;
33+ use function str_starts_with ;
3134use function stripcslashes ;
3235use function substr ;
3336use function trim ;
@@ -514,8 +517,6 @@ public static function decorateColumnMetaDefault(array $columnMeta): array
514517 // Could be null or empty string here
515518 if ($ columnMeta ['Default ' ] === null ) {
516519 $ metaDefault ['DefaultType ' ] = $ columnMeta ['Null ' ] === 'YES ' ? 'NULL ' : 'NONE ' ;
517- } else {
518- $ columnMeta ['DefaultValue ' ] = $ columnMeta ['Default ' ];
519520 }
520521
521522 break ;
@@ -531,8 +532,16 @@ public static function decorateColumnMetaDefault(array $columnMeta): array
531532 break ;
532533 default :
533534 if (substr ((string ) $ columnMeta ['Type ' ], -4 ) === 'text ' ) {
534- $ textDefault = substr ($ columnMeta ['Default ' ], 1 , -1 );
535- $ metaDefault ['DefaultValue ' ] = stripcslashes ($ textDefault );
535+ if (
536+ mb_strlen ($ columnMeta ['Default ' ]) >= 2 &&
537+ str_starts_with ($ columnMeta ['Default ' ], "' " ) &&
538+ str_ends_with ($ columnMeta ['Default ' ], "' " )
539+ ) {
540+ $ textDefault = substr ($ columnMeta ['Default ' ], 1 , -1 );
541+ $ metaDefault ['DefaultValue ' ] = stripcslashes ($ textDefault );
542+ } else {
543+ $ metaDefault ['DefaultValue ' ] = $ columnMeta ['Default ' ];
544+ }
536545 } else {
537546 $ metaDefault ['DefaultValue ' ] = $ columnMeta ['Default ' ];
538547 }
0 commit comments