@@ -165,7 +165,8 @@ public function testIndexValidation(): void
165165 $ validator = new Index (
166166 $ attributes ,
167167 $ database ->getAdapter ()->getMaxIndexLength (),
168- $ database ->getAdapter ()->getInternalIndexesKeys ()
168+ $ database ->getAdapter ()->getInternalIndexesKeys (),
169+ $ database ->getAdapter ()->getSupportForIndexArray ()
169170 );
170171
171172 $ errorMessage = 'Index length 701 is larger than the size for title1: 700" ' ;
@@ -239,7 +240,8 @@ public function testIndexValidation(): void
239240 $ validator = new Index (
240241 $ attributes ,
241242 $ database ->getAdapter ()->getMaxIndexLength (),
242- $ database ->getAdapter ()->getInternalIndexesKeys ()
243+ $ database ->getAdapter ()->getInternalIndexesKeys (),
244+ $ database ->getAdapter ()->getSupportForIndexArray ()
243245 );
244246 $ errorMessage = 'Attribute "integer" cannot be part of a FULLTEXT index, must be of type string ' ;
245247 $ this ->assertFalse ($ validator ->isValid ($ indexes [0 ]));
@@ -296,6 +298,34 @@ public function testIndexValidation(): void
296298 }
297299 }
298300
301+ public function testIndexLengthZero (): void
302+ {
303+ /** @var Database $database */
304+ $ database = static ::getDatabase ();
305+
306+ $ database ->createCollection (__FUNCTION__ );
307+
308+ $ database ->createAttribute (__FUNCTION__ , 'title1 ' , Database::VAR_STRING , 1000 , true );
309+
310+ try {
311+ $ database ->createIndex (__FUNCTION__ , 'index_title1 ' , Database::INDEX_KEY , ['title1 ' ], [0 ]);
312+ $ this ->fail ('Failed to throw exception ' );
313+ } catch (Throwable $ e ) {
314+ $ this ->assertEquals ('Index length is longer than the maximum: ' .$ database ->getAdapter ()->getMaxIndexLength (), $ e ->getMessage ());
315+ }
316+
317+
318+ $ database ->createAttribute (__FUNCTION__ , 'title2 ' , Database::VAR_STRING , 100 , true );
319+ $ database ->createIndex (__FUNCTION__ , 'index_title2 ' , Database::INDEX_KEY , ['title2 ' ], [0 ]);
320+
321+ try {
322+ $ database ->updateAttribute (__FUNCTION__ , 'title2 ' , Database::VAR_STRING , 1000 , true );
323+ $ this ->fail ('Failed to throw exception ' );
324+ } catch (Throwable $ e ) {
325+ $ this ->assertEquals ('Index length is longer than the maximum: ' .$ database ->getAdapter ()->getMaxIndexLength (), $ e ->getMessage ());
326+ }
327+ }
328+
299329 public function testRenameIndex (): void
300330 {
301331 $ database = static ::getDatabase ();
0 commit comments