@@ -91,6 +91,64 @@ protected function createTableForDefault()
9191 $ this ->forge ->createTable ($ this ->table );
9292 }
9393
94+ protected function createTableForType ()
95+ {
96+ $ this ->forge ->dropTable ($ this ->table , true );
97+
98+ // missing types:
99+ // TINYINT,MEDIUMINT,BIT,YEAR,BINARY,VARBINARY,TINYTEXT,LONGTEXT,
100+ // JSON,Spatial data types
101+ // `id` must be INTEGER else SQLite3 error on not null for autoincrement field.
102+ $ fields = [
103+ 'id ' => ['type ' => 'INTEGER ' , 'constraint ' => 20 , 'auto_increment ' => true ],
104+ 'type_varchar ' => ['type ' => 'VARCHAR ' , 'constraint ' => 40 , 'null ' => true ],
105+ 'type_char ' => ['type ' => 'CHAR ' , 'constraint ' => 10 , 'null ' => true ],
106+ // TEXT should not be used on SQLSRV. It is deprecated.
107+ 'type_text ' => ['type ' => 'TEXT ' , 'null ' => true ],
108+ 'type_smallint ' => ['type ' => 'SMALLINT ' , 'null ' => true ],
109+ 'type_integer ' => ['type ' => 'INTEGER ' , 'null ' => true ],
110+ 'type_float ' => ['type ' => 'FLOAT ' , 'null ' => true ],
111+ 'type_numeric ' => ['type ' => 'NUMERIC ' , 'constraint ' => '18,2 ' , 'null ' => true ],
112+ 'type_date ' => ['type ' => 'DATE ' , 'null ' => true ],
113+ 'type_time ' => ['type ' => 'TIME ' , 'null ' => true ],
114+ // On SQLSRV `datetime2` is recommended.
115+ 'type_datetime ' => ['type ' => 'DATETIME ' , 'null ' => true ],
116+ 'type_timestamp ' => ['type ' => 'TIMESTAMP ' , 'null ' => true ],
117+ 'type_bigint ' => ['type ' => 'BIGINT ' , 'null ' => true ],
118+ 'type_real ' => ['type ' => 'REAL ' , 'null ' => true ],
119+ 'type_enum ' => ['type ' => 'ENUM ' , 'constraint ' => ['appel ' , 'pears ' ], 'null ' => true ],
120+ 'type_set ' => ['type ' => 'SET ' , 'constraint ' => ['one ' , 'two ' ], 'null ' => true ],
121+ 'type_mediumtext ' => ['type ' => 'MEDIUMTEXT ' , 'null ' => true ],
122+ 'type_double ' => ['type ' => 'DOUBLE ' , 'null ' => true ],
123+ 'type_decimal ' => ['type ' => 'DECIMAL ' , 'constraint ' => '18,4 ' , 'null ' => true ],
124+ 'type_blob ' => ['type ' => 'BLOB ' , 'null ' => true ],
125+ 'type_boolean ' => ['type ' => 'BOOLEAN ' , 'null ' => true ],
126+ ];
127+
128+ if ($ this ->db ->DBDriver === 'Postgre ' ) {
129+ unset(
130+ $ fields ['type_enum ' ],
131+ $ fields ['type_set ' ],
132+ $ fields ['type_mediumtext ' ],
133+ $ fields ['type_double ' ],
134+ $ fields ['type_blob ' ]
135+ );
136+ }
137+
138+ if ($ this ->db ->DBDriver === 'SQLSRV ' ) {
139+ unset(
140+ $ fields ['type_set ' ],
141+ $ fields ['type_mediumtext ' ],
142+ $ fields ['type_double ' ],
143+ $ fields ['type_blob ' ]
144+ );
145+ }
146+
147+ $ this ->forge ->addField ($ fields );
148+ $ this ->forge ->addKey ('id ' , true );
149+ $ this ->forge ->createTable ($ this ->table );
150+ }
151+
94152 abstract public function testGetFieldDataDefault (): void ;
95153
96154 protected function assertSameFieldData (array $ expected , array $ actual )
0 commit comments