2525use function func_get_arg ;
2626use function func_num_args ;
2727use function implode ;
28- use function is_string ;
2928use function preg_match ;
3029use function preg_match_all ;
3130use function sprintf ;
3231use function str_contains ;
33- use function strtok ;
34- use function strtolower ;
3532use function strtr ;
3633
3734use const CASE_LOWER ;
@@ -114,44 +111,24 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
114111 {
115112 $ tableColumn = array_change_key_case ($ tableColumn , CASE_LOWER );
116113
117- $ dbType = strtolower ($ tableColumn ['column_type ' ]);
118- $ dbType = strtok ($ dbType , '(), ' );
119- assert (is_string ($ dbType ));
120-
121- $ length = $ tableColumn ['length ' ] ?? strtok ('(), ' );
122-
123- $ fixed = false ;
124-
114+ $ dbType = $ tableColumn ['data_type ' ];
115+ $ length = null ;
125116 $ scale = 0 ;
126117 $ precision = null ;
118+ $ fixed = false ;
119+ $ values = [];
127120
128121 $ type = $ this ->platform ->getDoctrineTypeMapping ($ dbType );
129122
130- $ values = [];
131-
132123 switch ($ dbType ) {
133124 case 'char ' :
134- case 'binary ' :
135- $ fixed = true ;
125+ case 'varchar ' :
126+ $ length = $ tableColumn [ ' character_maximum_length ' ] ;
136127 break ;
137128
138- case 'float ' :
139- case 'double ' :
140- case 'real ' :
141- case 'numeric ' :
142- case 'decimal ' :
143- if (
144- preg_match (
145- '([A-Za-z]+\(([0-9]+),([0-9]+)\)) ' ,
146- $ tableColumn ['column_type ' ],
147- $ match ,
148- ) === 1
149- ) {
150- $ precision = (int ) $ match [1 ];
151- $ scale = (int ) $ match [2 ];
152- $ length = null ;
153- }
154-
129+ case 'binary ' :
130+ case 'varbinary ' :
131+ $ length = $ tableColumn ['character_octet_length ' ];
155132 break ;
156133
157134 case 'tinytext ' :
@@ -178,14 +155,24 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
178155 $ length = AbstractMySQLPlatform::LENGTH_LIMIT_MEDIUMBLOB ;
179156 break ;
180157
181- case 'tinyint ' :
182- case 'smallint ' :
183- case 'mediumint ' :
184- case 'int ' :
185- case 'integer ' :
186- case 'bigint ' :
187- case 'year ' :
188- $ length = null ;
158+ case 'float ' :
159+ case 'double ' :
160+ case 'real ' :
161+ case 'numeric ' :
162+ case 'decimal ' :
163+ $ precision = $ tableColumn ['numeric_precision ' ];
164+
165+ if (isset ($ tableColumn ['numeric_scale ' ])) {
166+ $ scale = $ tableColumn ['numeric_scale ' ];
167+ }
168+
169+ break ;
170+ }
171+
172+ switch ($ dbType ) {
173+ case 'char ' :
174+ case 'binary ' :
175+ $ fixed = true ;
189176 break ;
190177
191178 case 'enum ' :
@@ -200,7 +187,7 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
200187 }
201188
202189 $ options = [
203- 'length ' => $ length !== null ? ( int ) $ length : null ,
190+ 'length ' => $ length ,
204191 'unsigned ' => str_contains ($ tableColumn ['column_type ' ], 'unsigned ' ),
205192 'fixed ' => $ fixed ,
206193 'default ' => $ columnDefault ,
@@ -348,7 +335,12 @@ protected function selectTableColumns(string $databaseName, ?OptionallyQualified
348335SELECT
349336 c.TABLE_NAME AS %s,
350337 c.COLUMN_NAME,
351- %s AS COLUMN_TYPE,
338+ %s AS DATA_TYPE,
339+ c.COLUMN_TYPE,
340+ c.CHARACTER_MAXIMUM_LENGTH,
341+ c.CHARACTER_OCTET_LENGTH,
342+ c.NUMERIC_PRECISION,
343+ c.NUMERIC_SCALE,
352344 c.IS_NULLABLE,
353345 c.COLUMN_DEFAULT,
354346 c.EXTRA,
0 commit comments