@@ -38,16 +38,38 @@ public function createAttributes(): array
38
38
$ attributes = [];
39
39
40
40
foreach ($ columns as $ _column ) {
41
+
41
42
$ dataType = $ this ->getDataType ($ _column ->COLUMN_TYPE , $ _column ->DATA_TYPE );
42
- $ defaultValue = ($ _column ->COLUMN_DEFAULT ?? 'null ' ) ? ($ _column ->COLUMN_DEFAULT ?? 'null ' ) : "'' " ;
43
43
44
- $ defaultValue = ($ dataType == self ::BOOL_TYPE ) ? ((in_array ($ defaultValue , [0 , '' , "'' " ])) ? 'false ' :
45
- ((in_array ($ defaultValue , [1 , '1 ' ])) ? 'true ' : $ defaultValue )) : $ defaultValue ;
44
+ $ defaultValue = null ;
45
+ if ($ _column ->COLUMN_DEFAULT !== null ) {
46
+ $ defaultValue = $ _column ->COLUMN_DEFAULT ;
47
+
48
+ if ($ dataType == 'int ' ) {
49
+ $ defaultValue = intval ($ defaultValue );
50
+ }
51
+
52
+ if ($ dataType == self ::BOOL_TYPE ) {
53
+ if (in_array ($ defaultValue , [0 , '' , "'' " ])) {
54
+ $ defaultValue = 'false ' ;
55
+ } elseif (in_array ($ defaultValue , [1 , '1 ' ])) {
56
+ $ defaultValue = 'true ' ;
57
+ }
58
+ }
59
+ }
60
+
61
+ $ columnString = $ _column ->COLUMN_NAME ;
62
+ if (!in_array ($ _column ->COLUMN_DEFAULT , [null , 'NULL ' ])) {
63
+ $ columnString .= ' = ' . $ defaultValue ;
64
+ }
65
+ if ($ _column ->IS_NULLABLE === 'YES ' ) {
66
+ $ columnString .= ' = null ' ;
67
+ }
46
68
47
69
$ attributes [$ _column ->COLUMN_NAME ] =
48
70
$ this ->writeAttribute (
49
71
$ entityStubsPath ,
50
- $ _column -> COLUMN_NAME . (! in_array ( $ _column -> COLUMN_DEFAULT , [ null , ' NULL ' ]) ? ' = ' . $ defaultValue : '' ) ,
72
+ $ columnString ,
51
73
($ _column ->IS_NULLABLE === 'YES ' ? 'null| ' : '' ) . $ dataType
52
74
);
53
75
}
0 commit comments