@@ -91,8 +91,68 @@ public function test_converting_flow_to_dbal_schema_without_providing_pk_name()
91
91
);
92
92
}
93
93
94
- public function test_dbal_schema_to_flow_schema () : void
94
+ public function test_dbal_schema_to_flow_schema_dbal_36 () : void
95
95
{
96
+ // changeColumn was removed in doctrine/dbal 4.0
97
+ // We are using it to perform a different assertion since prior to 4.0 all
98
+ // columns were also getting precision set to 10 due to a bug that was executing precision set
99
+ // even when precision value was null.
100
+ if (!\method_exists (Table::class, 'changeColumn ' )) {
101
+ self ::markTestSkipped ('Doctrine DBAL >= 3.6+ < 4.0 ' );
102
+ }
103
+
104
+ self ::assertEquals (
105
+ schema (
106
+ int_schema ('int ' , nullable: false , metadata: DbalMetadata::primaryKey ('pk_test ' )->merge (DbalMetadata::precision (10 ))),
107
+ str_schema ('str ' , nullable: false , metadata: DbalMetadata::primaryKey ('pk_test ' )->merge (DbalMetadata::precision (10 ))),
108
+ int_schema ('bigint ' , nullable: false , metadata: DbalMetadata::precision (10 )),
109
+ str_schema ('str_with_length ' , true , DbalMetadata::length (255 )->merge (DbalMetadata::precision (10 ))),
110
+ str_schema ('str_unique ' , true , DbalMetadata::indexUnique ('idx_str_unique ' )->merge (DbalMetadata::precision (10 ))),
111
+ date_schema ('date ' , nullable: true , metadata: DbalMetadata::index ('idx_date ' )->merge (DbalMetadata::precision (10 ))),
112
+ float_schema ('float ' , nullable: true , metadata: DbalMetadata::precision (10 )->merge (DbalMetadata::scale (2 ))->merge (DbalMetadata::precision (10 ))),
113
+ float_schema ('float_default ' , metadata: DbalMetadata::scale (6 )->merge (DbalMetadata::precision (10 ))),
114
+ bool_schema ('bool ' , nullable: true , metadata: DbalMetadata::default (true )->merge (DbalMetadata::precision (10 ))),
115
+ json_schema ('json ' , nullable: true , metadata: DbalMetadata::platformOptions (['jsonb ' => true ])->merge (DbalMetadata::precision (10 ))),
116
+ json_schema ('list ' , metadata: DbalMetadata::columnDefinition ('integer[] ' )->merge (DbalMetadata::precision (10 ))),
117
+ json_schema ('map ' , metadata: DbalMetadata::comment ('test comment! ' )->merge (DbalMetadata::precision (10 ))),
118
+ ),
119
+ table_schema_to_flow_schema (
120
+ new Table (
121
+ 'test ' ,
122
+ [
123
+ new Column ('int ' , Type::getType ('integer ' ), ['notnull ' => true ]),
124
+ new Column ('str ' , Type::getType ('string ' ), ['notnull ' => true ]), // pk changes nullable true into false
125
+ new Column ('bigint ' , Type::getType ('bigint ' ), ['notnull ' => true ]),
126
+ new Column ('str_with_length ' , Type::getType ('string ' ), ['notnull ' => false , 'length ' => 255 ]),
127
+ new Column ('str_unique ' , Type::getType ('string ' ), ['notnull ' => false ]),
128
+ new Column ('float ' , Type::getType ('float ' ), ['notnull ' => false , 'precision ' => 10 , 'scale ' => 2 ]),
129
+ new Column ('float_default ' , Type::getType ('float ' ), ['notnull ' => true , 'scale ' => 6 ]),
130
+ new Column ('bool ' , Type::getType ('boolean ' ), ['notnull ' => false , 'default ' => true ]),
131
+ new Column ('json ' , Type::getType ('json ' ), ['notnull ' => false , 'platformOptions ' => ['jsonb ' => true ]]),
132
+ new Column ('list ' , Type::getType ('json ' ), ['notnull ' => true , 'columnDefinition ' => 'integer[] ' ]),
133
+ new Column ('map ' , Type::getType ('json ' ), ['notnull ' => true , 'comment ' => 'test comment! ' ]),
134
+ new Column ('date ' , Type::getType ('date_immutable ' ), ['notnull ' => false ]),
135
+ ],
136
+ [
137
+ new Index ('pk_test ' , ['int ' , 'str ' ], true , true ),
138
+ new Index ('idx_date ' , ['date ' ], false , false ),
139
+ new Index ('idx_str_unique ' , ['str_unique ' ], true , false ),
140
+ ]
141
+ )
142
+ )
143
+ );
144
+ }
145
+
146
+ public function test_dbal_schema_to_flow_schema_dbal_40 () : void
147
+ {
148
+ // changeColumn was removed in doctrine/dbal 4.0
149
+ // We are using it to perform a different assertion since prior to 4.0 all
150
+ // columns were also getting precision set to 10 due to a bug that was executing precision set
151
+ // even when precision value was null.
152
+ if (\method_exists (Table::class, 'changeColumn ' )) {
153
+ self ::markTestSkipped ('Doctrine DBAL >= 4.0+ ' );
154
+ }
155
+
96
156
self ::assertEquals (
97
157
schema (
98
158
int_schema ('int ' , nullable: false , metadata: DbalMetadata::primaryKey ('pk_test ' )),
0 commit comments