44
55namespace Pfilsx \PostgreSQLDoctrine \DBAL \Schema ;
66
7-
87use Doctrine \DBAL \Result ;
98use Doctrine \DBAL \Schema \Identifier ;
109use Doctrine \DBAL \Types \JsonType ;
@@ -126,7 +125,7 @@ protected function _getPortableTableColumnDefinition($tableColumn): Column
126125
127126 if (strtolower ($ tableColumn ['type ' ]) === 'varchar ' || strtolower ($ tableColumn ['type ' ]) === 'bpchar ' ) {
128127 // get length from varchar definition
129- $ length = preg_replace ('~.*\(([0-9]*)\).*~ ' , '$1 ' , $ tableColumn ['complete_type ' ]);
128+ $ length = preg_replace ('~.*\(([0-9]*)\).*~ ' , '$1 ' , $ tableColumn ['complete_type ' ]);
130129 $ tableColumn ['length ' ] = $ length ;
131130 }
132131
@@ -139,8 +138,8 @@ protected function _getPortableTableColumnDefinition($tableColumn): Column
139138 && preg_match ("/^nextval\('(.*)'(::.*)?\)$/ " , $ tableColumn ['default ' ], $ matches ) === 1
140139 ) {
141140 $ tableColumn ['sequence ' ] = $ matches [1 ];
142- $ tableColumn ['default ' ] = null ;
143- $ autoincrement = true ;
141+ $ tableColumn ['default ' ] = null ;
142+ $ autoincrement = true ;
144143 }
145144
146145 if ($ tableColumn ['default ' ] !== null ) {
@@ -171,21 +170,21 @@ protected function _getPortableTableColumnDefinition($tableColumn): Column
171170 }
172171
173172 $ precision = null ;
174- $ scale = null ;
175- $ jsonb = null ;
173+ $ scale = null ;
174+ $ jsonb = null ;
176175
177176 $ dbType = strtolower ($ tableColumn ['type ' ]);
178177 if (
179178 $ tableColumn ['domain_type ' ] !== null
180179 && $ tableColumn ['domain_type ' ] !== ''
181180 && ! $ this ->_platform ->hasDoctrineTypeMappingFor ($ tableColumn ['type ' ])
182181 ) {
183- $ dbType = strtolower ($ tableColumn ['domain_type ' ]);
182+ $ dbType = strtolower ($ tableColumn ['domain_type ' ]);
184183 $ tableColumn ['complete_type ' ] = $ tableColumn ['domain_complete_type ' ];
185184 }
186185
187- $ type = $ this ->_platform ->getDoctrineTypeMapping ($ dbType );
188- $ type = $ this ->extractDoctrineTypeFromComment ($ tableColumn ['comment ' ], $ type );
186+ $ type = $ this ->_platform ->getDoctrineTypeMapping ($ dbType );
187+ $ type = $ this ->extractDoctrineTypeFromComment ($ tableColumn ['comment ' ], $ type );
189188 $ tableColumn ['comment ' ] = $ this ->removeDoctrineTypeFromComment ($ tableColumn ['comment ' ], $ type );
190189
191190 switch ($ dbType ) {
@@ -197,7 +196,8 @@ protected function _getPortableTableColumnDefinition($tableColumn): Column
197196 case 'int8 ' :
198197 case 'integer ' :
199198 $ tableColumn ['default ' ] = $ this ->fixVersion94NegativeNumericDefaultValue ($ tableColumn ['default ' ]);
200- $ length = null ;
199+ $ length = null ;
200+
201201 break ;
202202
203203 case 'bool ' :
@@ -211,21 +211,25 @@ protected function _getPortableTableColumnDefinition($tableColumn): Column
211211 }
212212
213213 $ length = null ;
214+
214215 break ;
215216
216217 case 'text ' :
217218 case '_varchar ' :
218219 case 'varchar ' :
219220 $ tableColumn ['default ' ] = $ this ->parseDefaultExpression ($ tableColumn ['default ' ]);
220- $ fixed = false ;
221+ $ fixed = false ;
222+
221223 break ;
222224 case 'interval ' :
223225 $ fixed = false ;
226+
224227 break ;
225228
226229 case 'char ' :
227230 case 'bpchar ' :
228231 $ fixed = true ;
232+
229233 break ;
230234
231235 case 'float ' :
@@ -247,19 +251,21 @@ protected function _getPortableTableColumnDefinition($tableColumn): Column
247251 ) === 1
248252 ) {
249253 $ precision = $ match [1 ];
250- $ scale = $ match [2 ];
251- $ length = null ;
254+ $ scale = $ match [2 ];
255+ $ length = null ;
252256 }
253257
254258 break ;
255259
256260 case 'year ' :
257261 $ length = null ;
262+
258263 break ;
259264
260265 // PostgreSQL 9.4+ only
261266 case 'jsonb ' :
262267 $ jsonb = true ;
268+
263269 break ;
264270 }
265271
@@ -274,15 +280,15 @@ protected function _getPortableTableColumnDefinition($tableColumn): Column
274280 }
275281
276282 $ options = [
277- 'length ' => $ length ,
278- 'notnull ' => (bool ) $ tableColumn ['isnotnull ' ],
279- 'default ' => $ tableColumn ['default ' ],
280- 'precision ' => $ precision ,
281- 'scale ' => $ scale ,
282- 'fixed ' => $ fixed ,
283- 'unsigned ' => false ,
283+ 'length ' => $ length ,
284+ 'notnull ' => (bool ) $ tableColumn ['isnotnull ' ],
285+ 'default ' => $ tableColumn ['default ' ],
286+ 'precision ' => $ precision ,
287+ 'scale ' => $ scale ,
288+ 'fixed ' => $ fixed ,
289+ 'unsigned ' => false ,
284290 'autoincrement ' => $ autoincrement ,
285- 'comment ' => isset ($ tableColumn ['comment ' ]) && $ tableColumn ['comment ' ] !== ''
291+ 'comment ' => isset ($ tableColumn ['comment ' ]) && $ tableColumn ['comment ' ] !== ''
286292 ? $ tableColumn ['comment ' ]
287293 : null ,
288294 ];
@@ -347,12 +353,12 @@ private function buildQueryConditions($tableName): array
347353 if ($ tableName !== null ) {
348354 if (str_contains ($ tableName , '. ' )) {
349355 [$ schemaName , $ tableName ] = explode ('. ' , $ tableName );
350- $ conditions [] = 'n.nspname = ' . $ this ->_platform ->quoteStringLiteral ($ schemaName );
356+ $ conditions [] = 'n.nspname = ' . $ this ->_platform ->quoteStringLiteral ($ schemaName );
351357 } else {
352358 $ conditions [] = 'n.nspname = ANY(current_schemas(false)) ' ;
353359 }
354360
355- $ identifier = new Identifier ($ tableName );
361+ $ identifier = new Identifier ($ tableName );
356362 $ conditions [] = 'c.relname = ' . $ this ->_platform ->quoteStringLiteral ($ identifier ->getName ());
357363 }
358364
0 commit comments