|
3 | 3 |
|
4 | 4 | final class TablePropsTest extends TestCase{ |
5 | 5 |
|
6 | | - function table_props_test($tokens, $props_expect){ |
7 | | - |
8 | | - $obj = new iamcal\SQLParser(); |
9 | | - $i = 0; |
10 | | - $props = $obj->parse_table_props($tokens, $i); |
11 | | - |
12 | | - $this->assertEquals($props, $props_expect); |
13 | | - } |
| 6 | + # table_options: |
| 7 | + # table_option [[,] table_option] ... |
| 8 | + # |
| 9 | + # table_option: |
| 10 | + # AUTO_INCREMENT [=] value |
| 11 | + # | AVG_ROW_LENGTH [=] value |
| 12 | + # | [DEFAULT] CHARACTER SET [=] charset_name |
| 13 | + # | CHECKSUM [=] {0 | 1} |
| 14 | + # | [DEFAULT] COLLATE [=] collation_name |
| 15 | + # | COMMENT [=] 'string' |
| 16 | + # | COMPRESSION [=] {'ZLIB'|'LZ4'|'NONE'} |
| 17 | + # | CONNECTION [=] 'connect_string' |
| 18 | + # | {DATA|INDEX} DIRECTORY [=] 'absolute path to directory' |
| 19 | + # | DELAY_KEY_WRITE [=] {0 | 1} |
| 20 | + # | ENCRYPTION [=] {'Y' | 'N'} |
| 21 | + # | ENGINE [=] engine_name |
| 22 | + # | INSERT_METHOD [=] { NO | FIRST | LAST } |
| 23 | + # | KEY_BLOCK_SIZE [=] value |
| 24 | + # | MAX_ROWS [=] value |
| 25 | + # | MIN_ROWS [=] value |
| 26 | + # | PACK_KEYS [=] {0 | 1 | DEFAULT} |
| 27 | + # | PASSWORD [=] 'string' |
| 28 | + # | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT} |
| 29 | + # | STATS_AUTO_RECALC [=] {DEFAULT|0|1} |
| 30 | + # | STATS_PERSISTENT [=] {DEFAULT|0|1} |
| 31 | + # | STATS_SAMPLE_PAGES [=] value |
| 32 | + # | TABLESPACE tablespace_name [STORAGE {DISK|MEMORY|DEFAULT}] |
| 33 | + # | UNION [=] (tbl_name[,tbl_name]...) |
14 | 34 |
|
15 | 35 |
|
16 | 36 | function testEqualsIsOptional(){ |
@@ -49,44 +69,12 @@ function testTwoWordProps(){ |
49 | 69 | # TODO: case conversion, multiple options, optional commas |
50 | 70 |
|
51 | 71 |
|
52 | | - function get_first_table($str){ |
53 | | - $obj = new iamcal\SQLParser(); |
54 | | - $obj->parse($str); |
55 | | - |
56 | | - $tables = array_keys($obj->tables); |
57 | | - $first_key = $tables[0]; |
58 | | - |
59 | | - return $obj->tables[$first_key]; |
60 | | - } |
61 | | - |
62 | | - function testGeneralCreation(){ |
63 | | - |
64 | | - $tbl = $this->get_first_table("CREATE TABLE foo"); |
65 | | - $this->assertEquals($tbl['name'], "foo"); |
66 | | - $this->assertEquals(array_key_exists('temporary', $tbl['props']), false); |
67 | | - |
68 | | - $tbl = $this->get_first_table("CREATE TEMPORARY TABLE foo"); |
69 | | - $this->assertEquals($tbl['name'], "foo"); |
70 | | - $this->assertEquals($tbl['props']['temporary'], true); |
71 | | - } |
72 | | - |
73 | | - function testIfNotExists(){ |
74 | | - |
75 | | - $tbl1 = $this->get_first_table("CREATE TABLE bar"); |
76 | | - $tbl2 = $this->get_first_table("CREATE TABLE IF NOT EXISTS bar"); |
77 | | - |
78 | | - # these props wont match, since it's the src sql |
79 | | - unset($tbl1['sql']); |
80 | | - unset($tbl2['sql']); |
81 | | - |
82 | | - $this->assertEquals(var_export($tbl1, true), var_export($tbl2, true)); |
83 | | - } |
84 | | - |
85 | | - function testCreateTableLike(){ |
| 72 | + function table_props_test($tokens, $props_expect){ |
86 | 73 |
|
87 | | - $tbl = $this->get_first_table("CREATE TABLE foo LIKE `bar`"); |
| 74 | + $obj = new iamcal\SQLParser(); |
| 75 | + $i = 0; |
| 76 | + $props = $obj->parse_table_props($tokens, $i); |
88 | 77 |
|
89 | | - $this->assertEquals($tbl['name'], "foo"); |
90 | | - $this->assertEquals($tbl['like'], "bar"); |
| 78 | + $this->assertEquals($props, $props_expect); |
91 | 79 | } |
92 | 80 | } |
0 commit comments