Skip to content

Commit f67869e

Browse files
iifawziwilliamdes
authored andcommitted
Fixing the key options and adding a test for the invisible issue
Signed-off-by: Fawzi E. Abdulfattah <iifawzie@gmail.com>
1 parent b245139 commit f67869e

File tree

5 files changed

+72
-25
lines changed

5 files changed

+72
-25
lines changed

src/Components/Key.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ class Key extends Component
4545
4,
4646
'var',
4747
),
48-
'INVISIBLE' => 1,
49-
'VISIBLE' => 1,
48+
// MariaDB options
49+
'CLUSTERING' => array(
50+
4,
51+
'var=',
52+
),
5053
'ENGINE_ATTRIBUTE' => array(
51-
3,
54+
5,
5255
'var=',
5356
),
5457
'SECONDARY_ENGINE_ATTRIBUTE' => array(
55-
4,
58+
5,
5659
'var=',
5760
),
58-
61+
// MariaDB & MySQL options
62+
'VISIBLE' => 6,
63+
'INVISIBLE' => 6,
5964
// MariaDB options
60-
61-
'CLUSTERING' => array(
62-
4,
63-
'var=',
64-
),
65-
'IGNORED' => 1,
66-
'NOT IGNORED' => 1,
65+
'IGNORED' => 10,
66+
'NOT IGNORED' => 10,
6767
);
6868

6969
/**

tests/Components/KeyTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,33 @@ public function testParseKeyWithLengthWithAllOptions()
101101
$this->assertEquals('alias_type_idx', $component->name);
102102
$this->assertEquals(new OptionsArray(
103103
array(
104-
1 => 'VISIBLE',
104+
1 => array(
105+
'name' => 'KEY_BLOCK_SIZE',
106+
'equals' => true,
107+
'expr' => '1',
108+
'value' => '1',
109+
),
105110
2 => array(
106111
'name' => 'USING',
107112
'equals' => false,
108113
'expr' => 'BTREE',
109114
'value' => 'BTREE',
110115
),
111-
3 => array(
112-
'name' => 'ENGINE_ATTRIBUTE',
113-
'equals' => true,
114-
'expr' => '\'foo\'',
115-
'value' => 'foo',
116-
),
117116
4 => array(
118117
'name' => 'COMMENT',
119118
'equals' => false,
120119
'expr' => '\'my comment\'',
121120
'value' => 'my comment',
122121
),
123-
12 => array(
124-
'name' => 'KEY_BLOCK_SIZE',
122+
5 => array(
123+
'name' => 'ENGINE_ATTRIBUTE',
125124
'equals' => true,
126-
'expr' => '1',
127-
'value' => '1',
125+
'expr' => '\'foo\'',
126+
'value' => 'foo',
128127
),
129-
13 => 'INVISIBLE',
130-
14 => array(
128+
6 => 'VISIBLE',
129+
12 => 'INVISIBLE',
130+
13 => array(
131131
'name' => 'SECONDARY_ENGINE_ATTRIBUTE',
132132
'equals' => true,
133133
'expr' => '\'bar\'',

tests/Parser/CreateStatementTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function createProvider()
4747
array('parser/parseCreateTableLike'),
4848
array('parser/parseCreateTableSpatial'),
4949
array('parser/parseCreateTableTimestampWithPrecision'),
50+
array('parser/parseCreateTableWithInvisibleKey'),
5051
array('parser/parseCreateTrigger'),
5152
array('parser/parseCreateUser'),
5253
array('parser/parseCreateView'),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE TABLE `animes_comments` (
2+
`anime_comment_id` bigint unsigned NOT NULL AUTO_INCREMENT,
3+
`anime_id` bigint unsigned NOT NULL,
4+
`user_id` bigint unsigned NOT NULL,
5+
`comment_text` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL,
6+
`comment_at` datetime DEFAULT NULL,
7+
PRIMARY KEY (`anime_comment_id`),
8+
KEY `animes_comments_animes_fk` (`anime_id`) invisible,
9+
KEY `animes_comments_users_fk` (`user_id`),
10+
KEY `comment_at_idx` (`comment_at`) ,
11+
CONSTRAINT `animes_comments_animes_fk` FOREIGN KEY (`anime_id`) REFERENCES `animes` (`anime_id`) ON DELETE CASCADE ON UPDATE RESTRICT,
12+
CONSTRAINT `animes_comments_users_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE RESTRICT)

0 commit comments

Comments
 (0)