@@ -842,9 +842,13 @@ protected function getColumnPhpType(ColumnSchemaInterface $column): string
842842 *
843843 * @return mixed The normalized default value.
844844 */
845- private function normalizeDefaultValue (? string $ defaultValue , ColumnSchemaInterface $ column ): mixed
845+ private function normalizeDefaultValue (string | null $ defaultValue , ColumnSchemaInterface $ column ): mixed
846846 {
847- if ($ defaultValue === null || $ column ->isPrimaryKey ()) {
847+ if (
848+ $ defaultValue === null
849+ || $ column ->isPrimaryKey ()
850+ || str_starts_with ($ defaultValue , 'NULL:: ' )
851+ ) {
848852 return null ;
849853 }
850854
@@ -859,19 +863,13 @@ private function normalizeDefaultValue(?string $defaultValue, ColumnSchemaInterf
859863 return new Expression ($ defaultValue );
860864 }
861865
862- if (preg_match ("/^B?'(.*?)'::/ " , $ defaultValue , $ matches ) === 1 ) {
863- return $ column ->getType () === self ::TYPE_BINARY && str_starts_with ($ matches [1 ], '\\x ' )
864- ? hex2bin (substr ($ matches [1 ], 2 ))
865- : $ column ->phpTypecast ($ matches [1 ]);
866- }
866+ $ value = preg_replace ("/^B?['(](.*?)[)']::[^:]+$/ " , '$1 ' , $ defaultValue );
867867
868- if (preg_match ('/^(\()?(.*?)(?(1)\))(?:::.+)?$/ ' , $ defaultValue , $ matches ) === 1 ) {
869- return $ matches [2 ] !== 'NULL '
870- ? $ column ->phpTypecast ($ matches [2 ])
871- : null ;
868+ if ($ column ->getType () === self ::TYPE_BINARY && str_starts_with ($ value , '\\x ' )) {
869+ return hex2bin (substr ($ value , 2 ));
872870 }
873871
874- return $ column ->phpTypecast ($ defaultValue );
872+ return $ column ->phpTypecast ($ value );
875873 }
876874
877875 /**
0 commit comments