Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 240bbf8

Browse files
committed
Support table, column, and index comments, and test encoding
1 parent 7e972f1 commit 240bbf8

File tree

4 files changed

+175
-71
lines changed

4 files changed

+175
-71
lines changed

tests/WP_SQLite_Driver_Tests.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,59 @@ public function testShowCreateTableWithAlterAndCreateIndex() {
343343
);
344344
}
345345

346+
public function testShowCreateTableWithComments(): void {
347+
$this->assertQuery(
348+
"CREATE TABLE _tmp_table (
349+
id INT NOT NULL COMMENT 'Column 1 comment',
350+
name VARCHAR(255) NULL DEFAULT 'test' COMMENT 'Column 2 comment',
351+
special_chars_1 TEXT NOT NULL COMMENT '\'',
352+
special_chars_2 TEXT NOT NULL COMMENT '''',
353+
special_chars_3 TEXT NOT NULL COMMENT '\"',
354+
special_chars_4 TEXT NOT NULL COMMENT '\\\"',
355+
special_chars_5 TEXT NOT NULL COMMENT '`',
356+
special_chars_6 TEXT NOT NULL COMMENT '\0',
357+
special_chars_7 TEXT NOT NULL COMMENT '\n',
358+
special_chars_8 TEXT NOT NULL COMMENT '\r',
359+
special_chars_9 TEXT NOT NULL COMMENT '\t',
360+
special_chars_10 TEXT NOT NULL COMMENT '\032',
361+
special_chars_11 TEXT NOT NULL COMMENT '\\\\',
362+
special_chars_12 TEXT NOT NULL COMMENT '🙂',
363+
special_chars_13 TEXT NOT NULL COMMENT '\🙂',
364+
INDEX idx_id (id) COMMENT 'Index comment'
365+
) COMMENT='Table comment'"
366+
);
367+
368+
$results = $this->assertQuery(
369+
'SHOW CREATE TABLE _tmp_table;'
370+
);
371+
$this->assertSame(
372+
implode(
373+
"\n",
374+
array(
375+
'CREATE TABLE `_tmp_table` (',
376+
" `id` int NOT NULL COMMENT 'Column 1 comment',",
377+
" `name` varchar(255) DEFAULT 'test' COMMENT 'Column 2 comment',",
378+
" `special_chars_1` text NOT NULL COMMENT '''',",
379+
" `special_chars_2` text NOT NULL COMMENT '''',",
380+
" `special_chars_3` text NOT NULL COMMENT '\"',",
381+
" `special_chars_4` text NOT NULL COMMENT '\"',",
382+
" `special_chars_5` text NOT NULL COMMENT '`',",
383+
" `special_chars_6` text NOT NULL COMMENT '\\0',",
384+
" `special_chars_7` text NOT NULL COMMENT '\\n',",
385+
" `special_chars_8` text NOT NULL COMMENT '\\r',",
386+
" `special_chars_9` text NOT NULL COMMENT ' ',",
387+
" `special_chars_10` text NOT NULL COMMENT '" . chr( 26 ) . "',",
388+
" `special_chars_11` text NOT NULL COMMENT '\\\\',",
389+
" `special_chars_12` text NOT NULL COMMENT '🙂',",
390+
" `special_chars_13` text NOT NULL COMMENT '🙂',",
391+
" KEY `idx_id` (`id`) COMMENT 'Index comment'",
392+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Table comment'",
393+
)
394+
),
395+
$results[0]->{'Create Table'}
396+
);
397+
}
398+
346399
public function testCreateTablesWithIdenticalIndexNames() {
347400
$this->assertQuery(
348401
"CREATE TABLE _tmp_table_a (

0 commit comments

Comments
 (0)