File tree 4 files changed +40
-13
lines changed
4 files changed +40
-13
lines changed Original file line number Diff line number Diff line change @@ -67,11 +67,13 @@ public function getPhpCode() : string
67
67
}
68
68
}
69
69
70
- return '(new \\' . static ::class . '( '
71
- . $ this ->max_string_length
72
- . ($ this ->character_set !== null ? ', \'' . $ this ->character_set . '\'' : '' )
73
- . ($ this ->collation !== null ? ', \'' . $ this ->collation . '\'' : '' )
74
- . ')) '
70
+ $ args = [
71
+ $ this ->max_string_length ,
72
+ $ this ->character_set === null ? 'null ' : "' {$ this ->character_set }' " ,
73
+ $ this ->collation === null ? 'null ' : "' {$ this ->collation }' " ,
74
+ ];
75
+
76
+ return '(new \\' . static ::class . '( ' . implode (', ' , $ args ) . ')) '
75
77
. $ default
76
78
. $ this ->getNullablePhp ();
77
79
}
Original file line number Diff line number Diff line change @@ -8,12 +8,13 @@ trait TextTrait
8
8
public function getPhpCode () : string
9
9
{
10
10
$ default = $ this ->getDefault () !== null ? '\'' . $ this ->getDefault () . '\'' : 'null ' ;
11
-
12
- return '(new \\' . static ::class . '( '
13
- . ($ this ->character_set !== null && $ this ->collation !== null
14
- ? ', \'' . $ this ->character_set . '\'' . ', \'' . $ this ->collation . '\''
15
- : '' )
16
- . ')) '
11
+
12
+ $ args = [
13
+ $ this ->character_set === null ? 'null ' : "' {$ this ->character_set }' " ,
14
+ $ this ->collation === null ? 'null ' : "' {$ this ->collation }' " ,
15
+ ];
16
+
17
+ return '(new \\' . static ::class . '( ' . implode (', ' , $ args ) . ')) '
17
18
. ($ this ->hasDefault () ? '->setDefault( ' . $ default . ') ' : '' )
18
19
. $ this ->getNullablePhp ();
19
20
}
Original file line number Diff line number Diff line change @@ -34,7 +34,17 @@ public function testSimpleParse()
34
34
35
35
// specific parsing checks
36
36
$ this ->assertInstanceOf (TableDefinition::class, $ table_defs ['tweets ' ]);
37
+ $ this ->assertEquals ('utf8mb4 ' , $ table_defs ['tweets ' ]->columns ['title ' ]->getCharacterSet ());
38
+ $ this ->assertEquals ('utf8mb4_unicode_ci ' , $ table_defs ['tweets ' ]->columns ['title ' ]->getCollation ());
37
39
$ this ->assertEquals ('utf8mb4 ' , $ table_defs ['tweets ' ]->columns ['text ' ]->getCharacterSet ());
38
40
$ this ->assertEquals ('utf8mb4_unicode_ci ' , $ table_defs ['tweets ' ]->columns ['text ' ]->getCollation ());
41
+
42
+ $ this ->assertInstanceOf (TableDefinition::class, $ table_defs ['texts ' ]);
43
+ $ this ->assertEquals ('utf8mb4 ' , $ table_defs ['texts ' ]->columns ['title_char_col ' ]->getCharacterSet ());
44
+ $ this ->assertEquals ('utf8mb4_unicode_ci ' , $ table_defs ['texts ' ]->columns ['title_char_col ' ]->getCollation ());
45
+ $ this ->assertNull ($ table_defs ['texts ' ]->columns ['title_col ' ]->getCharacterSet ());
46
+ $ this ->assertEquals ('utf8mb4_unicode_ci ' , $ table_defs ['texts ' ]->columns ['title_col ' ]->getCollation ());
47
+ $ this ->assertNull ($ table_defs ['texts ' ]->columns ['title ' ]->getCharacterSet ());
48
+ $ this ->assertNull ($ table_defs ['texts ' ]->columns ['title ' ]->getCollation ());
39
49
}
40
50
}
Original file line number Diff line number Diff line change @@ -60,11 +60,25 @@ CREATE TABLE `orders`
60
60
` created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
61
61
` modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
62
62
PRIMARY KEY (` id` )
63
- )ENGINE= InnoDB DEFAULT CHARSET= utf8 COLLATE= utf8_general_ci;
63
+ )
64
+ ENGINE= InnoDB DEFAULT CHARSET= utf8 COLLATE= utf8_general_ci;
64
65
65
66
CREATE TABLE `tweets ` (
66
67
` id` int (10 ) UNSIGNED NOT NULL AUTO_INCREMENT,
67
- ` text` varchar (256 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
68
+ ` title` varchar (256 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
69
+ ` text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
70
+ PRIMARY KEY (` id` )
71
+ )
72
+ ENGINE= InnoDB DEFAULT CHARSET= utf8 COLLATE= utf8_general_ci;
73
+
74
+ CREATE TABLE `texts ` (
75
+ ` id` int (10 ) UNSIGNED NOT NULL AUTO_INCREMENT,
76
+ ` title_char_col` varchar (256 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
77
+ ` title_col` varchar (256 ) COLLATE utf8mb4_unicode_ci,
78
+ ` title` varchar (256 )
79
+ ` text_char_col` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
80
+ ` text_col` text COLLATE utf8mb4_unicode_ci,
81
+ ` text` text ,
68
82
PRIMARY KEY (` id` )
69
83
)
70
84
ENGINE= InnoDB DEFAULT CHARSET= utf8 COLLATE= utf8_general_ci;
You can’t perform that action at this time.
0 commit comments