File tree 1 file changed +15
-7
lines changed 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 30
30
use function is_array ;
31
31
use function preg_match ;
32
32
use function preg_replace ;
33
+ use function str_replace ;
33
34
use function stripos ;
34
35
use function strpos ;
35
36
use function strtolower ;
@@ -99,18 +100,25 @@ protected function _getPortableTableColumnDefinition($tableColumn) : Column
99
100
{
100
101
$ tableColumn = array_change_key_case ($ tableColumn , CASE_LOWER );
101
102
102
- $ dbType = $ tableColumn ['type ' ];
103
- $ length = null ;
104
- $ fixed = false ;
105
- if (stripos (trim ($ tableColumn ['type ' ]), 'fixedstring ' ) === 0 ) {
103
+ $ dbType = $ columnType = trim ($ tableColumn ['type ' ]);
104
+ $ length = null ;
105
+ $ fixed = false ;
106
+ $ notnull = true ;
107
+
108
+ if (preg_match ('/(Nullable\((\w+)\))/i ' , $ columnType , $ matches )) {
109
+ $ columnType = str_replace ($ matches [1 ], $ matches [2 ], $ columnType );
110
+ $ notnull = false ;
111
+ }
112
+
113
+ if (stripos ($ columnType , 'fixedstring ' ) === 0 ) {
106
114
// get length from FixedString definition
107
- $ length = preg_replace ('~.*\(([0-9]*)\).*~ ' , '$1 ' , $ tableColumn [ ' type ' ] );
115
+ $ length = preg_replace ('~.*\(([0-9]*)\).*~ ' , '$1 ' , $ columnType );
108
116
$ dbType = 'fixedstring ' ;
109
117
$ fixed = true ;
110
118
}
111
119
112
120
$ unsigned = false ;
113
- if (stripos (trim ( $ tableColumn [ ' type ' ]) , 'uint ' ) === 0 ) {
121
+ if (stripos ($ columnType , 'uint ' ) === 0 ) {
114
122
$ unsigned = true ;
115
123
}
116
124
@@ -126,7 +134,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) : Column
126
134
127
135
$ options = [
128
136
'length ' => $ length ,
129
- 'notnull ' => true ,
137
+ 'notnull ' => $ notnull ,
130
138
'default ' => $ default ,
131
139
'primary ' => false ,
132
140
'fixed ' => $ fixed ,
You can’t perform that action at this time.
0 commit comments