@@ -38,16 +38,38 @@ public function createAttributes(): array
3838 $ attributes = [];
3939
4040 foreach ($ columns as $ _column ) {
41+
4142 $ dataType = $ this ->getDataType ($ _column ->COLUMN_TYPE , $ _column ->DATA_TYPE );
42- $ defaultValue = ($ _column ->COLUMN_DEFAULT ?? 'null ' ) ? ($ _column ->COLUMN_DEFAULT ?? 'null ' ) : "'' " ;
4343
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+ }
4668
4769 $ attributes [$ _column ->COLUMN_NAME ] =
4870 $ this ->writeAttribute (
4971 $ entityStubsPath ,
50- $ _column -> COLUMN_NAME . (! in_array ( $ _column -> COLUMN_DEFAULT , [ null , ' NULL ' ]) ? ' = ' . $ defaultValue : '' ) ,
72+ $ columnString ,
5173 ($ _column ->IS_NULLABLE === 'YES ' ? 'null| ' : '' ) . $ dataType
5274 );
5375 }
0 commit comments