3 namespace RedUNIT\Mysql;
5 use RedUNIT\Mysql as Mysql;
6 use RedBeanPHP\Facade as R;
11 * InnoDB has a maximum index length of 767 bytes, so with utf8mb4
12 * you can only store 191 characters. This means that when you
13 * subsequently add an index to the column you get a
14 * (not-so-obvious) MySQL-error. That's why we limit the varchar to
15 * 191 chars and then switch to TEXT type.
17 * @file RedUNIT/Mysql/Issue411.php
18 * @desc Tests intermediate varchar 191 type for MySQL utf8mb4.
19 * @author Gabor de Mooij and the RedBeanPHP Community
20 * @license New BSD/GPLv2
22 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
23 * This source file is subject to the New BSD/GPLv2 License that is bundled
24 * with this source code in the file license.txt.
26 class Issue411 extends Mysql
30 * Test varchar 191 condition.
34 public function testInnoDBIndexLimit()
37 $book = R::dispense( 'book' );
40 $columns = R::inspect( 'book' );
41 asrt( isset( $columns['text'] ), TRUE );
42 asrt( $columns['text'], 'varchar(191)' );
43 $book = $book->fresh();
44 $book->text = str_repeat( 'x', 190 );
46 $columns = R::inspect( 'book' );
47 asrt( isset( $columns['text'] ), TRUE );
48 asrt( $columns['text'], 'varchar(191)' );
49 $book = $book->fresh();
50 $book->text = str_repeat( 'x', 191 );
52 $columns = R::inspect( 'book' );
53 asrt( isset( $columns['text'] ), TRUE );
54 asrt( $columns['text'], 'varchar(191)' );
55 $book = $book->fresh();
56 $book->text = str_repeat( 'x', 192 );
58 $columns = R::inspect( 'book' );
59 asrt( isset( $columns['text'] ), TRUE );
60 asrt( $columns['text'], 'varchar(255)' );