File tree Expand file tree Collapse file tree
tests/system/Database/Live Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -182,6 +182,50 @@ protected function _processColumn($field)
182182
183183 //--------------------------------------------------------------------
184184
185+ /**
186+ * Process indexes
187+ *
188+ * @param string $table
189+ *
190+ * @return array
191+ */
192+ protected function _processIndexes ($ table )
193+ {
194+ $ sqls = [];
195+
196+ for ($ i = 0 , $ c = count ($ this ->keys ); $ i < $ c ; $ i ++)
197+ {
198+ $ this ->keys [$ i ] = (array )$ this ->keys [$ i ];
199+
200+ for ($ i2 = 0 , $ c2 = count ($ this ->keys [$ i ]); $ i2 < $ c2 ; $ i2 ++)
201+ {
202+ if (! isset ($ this ->fields [$ this ->keys [$ i ][$ i2 ]]))
203+ {
204+ unset($ this ->keys [$ i ][$ i2 ]);
205+ }
206+ }
207+ if (count ($ this ->keys [$ i ]) <= 0 )
208+ {
209+ continue ;
210+ }
211+
212+ if (in_array ($ i , $ this ->uniqueKeys ))
213+ {
214+ $ sqls [] = 'CREATE UNIQUE INDEX ' .$ this ->db ->escapeIdentifiers ($ table .'_ ' .implode ('_ ' , $ this ->keys [$ i ]))
215+ .' ON ' .$ this ->db ->escapeIdentifiers ($ table )
216+ .' ( ' .implode (', ' , $ this ->db ->escapeIdentifiers ($ this ->keys [$ i ])).'); ' ;
217+ continue ;
218+ }
219+
220+ $ sqls [] = 'CREATE INDEX ' .$ this ->db ->escapeIdentifiers ($ table .'_ ' .implode ('_ ' , $ this ->keys [$ i ]))
221+ .' ON ' .$ this ->db ->escapeIdentifiers ($ table )
222+ .' ( ' .implode (', ' , $ this ->db ->escapeIdentifiers ($ this ->keys [$ i ])).'); ' ;
223+ }
224+
225+ return $ sqls ;
226+ }
227+
228+ //--------------------------------------------------------------------
185229 /**
186230 * Field attribute TYPE
187231 *
Original file line number Diff line number Diff line change 11<?php namespace CodeIgniter \Database \Live ;
22
3+ use CodeIgniter \Database \Exceptions \DatabaseException ;
34use CodeIgniter \Test \CIDatabaseTestCase ;
45
56/**
@@ -41,6 +42,11 @@ public function testCreateTable()
4142
4243 public function testCreateTableWithAttributes ()
4344 {
45+ if ($ this ->db ->DBDriver == 'SQLite3 ' )
46+ {
47+ $ this ->markTestSkipped ('SQLite3 does not support comments on tables or columns. ' );
48+ }
49+
4450 $ this ->forge ->dropTable ('forge_test_attributes ' , true );
4551
4652 $ this ->forge ->addField ('id ' );
@@ -86,7 +92,7 @@ public function testAddFields()
8692 ]);
8793
8894 $ this ->forge ->addKey ('id ' , true );
89- $ this ->forge ->addKey (['username ' , 'active ' ], false , true );
95+ $ this ->forge ->addUniqueKey (['username ' , 'active ' ]);
9096 $ create = $ this ->forge ->createTable ('forge_test_fields ' , true );
9197
9298 //Check Field names
You can’t perform that action at this time.
0 commit comments