@@ -24,6 +24,12 @@ class TableColumn extends Object
2424 */
2525 public $ type ;
2626
27+ /**
28+ * @var string
29+ * @since 2.9.0
30+ */
31+ public $ defaultMapping ;
32+
2733 /**
2834 * @var bool|null
2935 */
@@ -66,13 +72,15 @@ class TableColumn extends Object
6672
6773 /**
6874 * @var bool
75+ * Starting from 2.9.0 it's false by default.
6976 */
70- public $ isPrimaryKey ;
77+ public $ isPrimaryKey = false ;
7178
7279 /**
7380 * @var bool
81+ * Starting from 2.9.0 it's false by default.
7482 */
75- public $ autoIncrement ;
83+ public $ autoIncrement = false ;
7684
7785 /**
7886 * @var string
@@ -287,4 +295,52 @@ public function removePKAppend()
287295
288296 return !empty ($ formattedAppend ) ? $ formattedAppend : null ;
289297 }
298+
299+ /**
300+ * @param bool $generalSchema
301+ * @return string|null
302+ * @since 2.9.0
303+ */
304+ public function getRenderLength ($ generalSchema )
305+ {
306+ $ length = $ this ->length ;
307+
308+ if ($ length === null ) {
309+ return $ length ;
310+ }
311+
312+ if (!$ generalSchema ) {
313+ if ($ length === 'max ' ) {
314+ return '\'max \'' ;
315+ }
316+
317+ return (string )$ length ;
318+ }
319+
320+ if (str_replace (' ' , '' , (string )$ length ) !== $ this ->getDefaultLength ()) {
321+ if ($ length === 'max ' ) {
322+ return '\'max \'' ;
323+ }
324+
325+ return (string )$ length ;
326+ }
327+
328+ return null ;
329+ }
330+
331+ private function getDefaultLength ()
332+ {
333+ if ($ this ->defaultMapping !== null ) {
334+ if (preg_match ('/\(([\d,]+)\)/ ' , $ this ->defaultMapping , $ matches )) {
335+ return $ matches [1 ];
336+ }
337+
338+ if (preg_match ('/\(max\)/ ' , $ this ->defaultMapping )) {
339+ // MSSQL
340+ return 'max ' ;
341+ }
342+ }
343+
344+ return null ;
345+ }
290346}
0 commit comments