Skip to content

Commit 72c52dc

Browse files
committed
Adjust data after fixes for #377
Signed-off-by: William Desportes <williamdes@wdes.fr>
1 parent bbdac1f commit 72c52dc

File tree

3 files changed

+318
-18
lines changed

3 files changed

+318
-18
lines changed

tests/Builder/AlterStatementTest.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,21 @@ public function testBuilderPartitions(): void
127127
$stmt = $parser->statements[0];
128128

129129
$this->assertEquals(
130-
'ALTER TABLE trips PARTITION BY RANGE (MONTH(trip_date)) ('
131-
. ' PARTITION p01 VALUES LESS THAN (02),'
132-
. ' PARTITION p02 VALUES LESS THAN (03),'
133-
. ' PARTITION p03 VALUES LESS THAN (04),'
134-
. ' PARTITION p04 VALUES LESS THAN (05),'
135-
. ' PARTITION p05 VALUES LESS THAN (06),'
136-
. ' PARTITION p06 VALUES LESS THAN (07),'
137-
. ' PARTITION p07 VALUES LESS THAN (08),'
138-
. ' PARTITION p08 VALUES LESS THAN (09),'
139-
. ' PARTITION p09 VALUES LESS THAN (10),'
140-
. ' PARTITION p10 VALUES LESS THAN (11),'
141-
. ' PARTITION p11 VALUES LESS THAN (12),'
142-
. ' PARTITION p12 VALUES LESS THAN (13),'
143-
. ' PARTITION pmaxval VALUES LESS THAN MAXVALUE )',
130+
'ALTER TABLE trips PARTITION BY RANGE (MONTH(trip_date)) (' . "\n"
131+
. 'PARTITION p01 VALUES LESS THAN (02),' . "\n"
132+
. 'PARTITION p02 VALUES LESS THAN (03),' . "\n"
133+
. 'PARTITION p03 VALUES LESS THAN (04),' . "\n"
134+
. 'PARTITION p04 VALUES LESS THAN (05),' . "\n"
135+
. 'PARTITION p05 VALUES LESS THAN (06),' . "\n"
136+
. 'PARTITION p06 VALUES LESS THAN (07),' . "\n"
137+
. 'PARTITION p07 VALUES LESS THAN (08),' . "\n"
138+
. 'PARTITION p08 VALUES LESS THAN (09),' . "\n"
139+
. 'PARTITION p09 VALUES LESS THAN (10),' . "\n"
140+
. 'PARTITION p10 VALUES LESS THAN (11),' . "\n"
141+
. 'PARTITION p11 VALUES LESS THAN (12),' . "\n"
142+
. 'PARTITION p12 VALUES LESS THAN (13),' . "\n"
143+
. 'PARTITION pmaxval VALUES LESS THAN MAXVALUE' . "\n"
144+
. ')',
144145
$stmt->build()
145146
);
146147
}

tests/data/parser/parseAlterTablePartitionByRange1.out

Lines changed: 267 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,8 +1736,273 @@
17361736
"2": "PARTITION BY"
17371737
}
17381738
},
1739-
"field": " RANGE (MONTH(trip_date)) ( PARTITION p01 VALUES LESS THAN (02), PARTITION p02 VALUES LESS THAN (03), PARTITION p03 VALUES LESS THAN (04), PARTITION p04 VALUES LESS THAN (05), PARTITION p05 VALUES LESS THAN (06), PARTITION p06 VALUES LESS THAN (07), PARTITION p07 VALUES LESS THAN (08), PARTITION p08 VALUES LESS THAN (09), PARTITION p09 VALUES LESS THAN (10), PARTITION p10 VALUES LESS THAN (11), PARTITION p11 VALUES LESS THAN (12), PARTITION p12 VALUES LESS THAN (13), PARTITION pmaxval VALUES LESS THAN MAXVALUE )",
1740-
"partitions": null,
1739+
"field": " RANGE (MONTH(trip_date)) ",
1740+
"partitions": [
1741+
{
1742+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1743+
"isSubpartition": false,
1744+
"name": "p01",
1745+
"type": "LESS THAN",
1746+
"expr": {
1747+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1748+
"database": null,
1749+
"table": null,
1750+
"column": null,
1751+
"expr": "(02)",
1752+
"alias": null,
1753+
"function": null,
1754+
"subquery": null
1755+
},
1756+
"subpartitions": null,
1757+
"options": {
1758+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1759+
"options": []
1760+
}
1761+
},
1762+
{
1763+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1764+
"isSubpartition": false,
1765+
"name": "p02",
1766+
"type": "LESS THAN",
1767+
"expr": {
1768+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1769+
"database": null,
1770+
"table": null,
1771+
"column": null,
1772+
"expr": "(03)",
1773+
"alias": null,
1774+
"function": null,
1775+
"subquery": null
1776+
},
1777+
"subpartitions": null,
1778+
"options": {
1779+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1780+
"options": []
1781+
}
1782+
},
1783+
{
1784+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1785+
"isSubpartition": false,
1786+
"name": "p03",
1787+
"type": "LESS THAN",
1788+
"expr": {
1789+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1790+
"database": null,
1791+
"table": null,
1792+
"column": null,
1793+
"expr": "(04)",
1794+
"alias": null,
1795+
"function": null,
1796+
"subquery": null
1797+
},
1798+
"subpartitions": null,
1799+
"options": {
1800+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1801+
"options": []
1802+
}
1803+
},
1804+
{
1805+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1806+
"isSubpartition": false,
1807+
"name": "p04",
1808+
"type": "LESS THAN",
1809+
"expr": {
1810+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1811+
"database": null,
1812+
"table": null,
1813+
"column": null,
1814+
"expr": "(05)",
1815+
"alias": null,
1816+
"function": null,
1817+
"subquery": null
1818+
},
1819+
"subpartitions": null,
1820+
"options": {
1821+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1822+
"options": []
1823+
}
1824+
},
1825+
{
1826+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1827+
"isSubpartition": false,
1828+
"name": "p05",
1829+
"type": "LESS THAN",
1830+
"expr": {
1831+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1832+
"database": null,
1833+
"table": null,
1834+
"column": null,
1835+
"expr": "(06)",
1836+
"alias": null,
1837+
"function": null,
1838+
"subquery": null
1839+
},
1840+
"subpartitions": null,
1841+
"options": {
1842+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1843+
"options": []
1844+
}
1845+
},
1846+
{
1847+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1848+
"isSubpartition": false,
1849+
"name": "p06",
1850+
"type": "LESS THAN",
1851+
"expr": {
1852+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1853+
"database": null,
1854+
"table": null,
1855+
"column": null,
1856+
"expr": "(07)",
1857+
"alias": null,
1858+
"function": null,
1859+
"subquery": null
1860+
},
1861+
"subpartitions": null,
1862+
"options": {
1863+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1864+
"options": []
1865+
}
1866+
},
1867+
{
1868+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1869+
"isSubpartition": false,
1870+
"name": "p07",
1871+
"type": "LESS THAN",
1872+
"expr": {
1873+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1874+
"database": null,
1875+
"table": null,
1876+
"column": null,
1877+
"expr": "(08)",
1878+
"alias": null,
1879+
"function": null,
1880+
"subquery": null
1881+
},
1882+
"subpartitions": null,
1883+
"options": {
1884+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1885+
"options": []
1886+
}
1887+
},
1888+
{
1889+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1890+
"isSubpartition": false,
1891+
"name": "p08",
1892+
"type": "LESS THAN",
1893+
"expr": {
1894+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1895+
"database": null,
1896+
"table": null,
1897+
"column": null,
1898+
"expr": "(09)",
1899+
"alias": null,
1900+
"function": null,
1901+
"subquery": null
1902+
},
1903+
"subpartitions": null,
1904+
"options": {
1905+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1906+
"options": []
1907+
}
1908+
},
1909+
{
1910+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1911+
"isSubpartition": false,
1912+
"name": "p09",
1913+
"type": "LESS THAN",
1914+
"expr": {
1915+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1916+
"database": null,
1917+
"table": null,
1918+
"column": null,
1919+
"expr": "(10)",
1920+
"alias": null,
1921+
"function": null,
1922+
"subquery": null
1923+
},
1924+
"subpartitions": null,
1925+
"options": {
1926+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1927+
"options": []
1928+
}
1929+
},
1930+
{
1931+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1932+
"isSubpartition": false,
1933+
"name": "p10",
1934+
"type": "LESS THAN",
1935+
"expr": {
1936+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1937+
"database": null,
1938+
"table": null,
1939+
"column": null,
1940+
"expr": "(11)",
1941+
"alias": null,
1942+
"function": null,
1943+
"subquery": null
1944+
},
1945+
"subpartitions": null,
1946+
"options": {
1947+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1948+
"options": []
1949+
}
1950+
},
1951+
{
1952+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1953+
"isSubpartition": false,
1954+
"name": "p11",
1955+
"type": "LESS THAN",
1956+
"expr": {
1957+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1958+
"database": null,
1959+
"table": null,
1960+
"column": null,
1961+
"expr": "(12)",
1962+
"alias": null,
1963+
"function": null,
1964+
"subquery": null
1965+
},
1966+
"subpartitions": null,
1967+
"options": {
1968+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1969+
"options": []
1970+
}
1971+
},
1972+
{
1973+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1974+
"isSubpartition": false,
1975+
"name": "p12",
1976+
"type": "LESS THAN",
1977+
"expr": {
1978+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
1979+
"database": null,
1980+
"table": null,
1981+
"column": null,
1982+
"expr": "(13)",
1983+
"alias": null,
1984+
"function": null,
1985+
"subquery": null
1986+
},
1987+
"subpartitions": null,
1988+
"options": {
1989+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
1990+
"options": []
1991+
}
1992+
},
1993+
{
1994+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
1995+
"isSubpartition": false,
1996+
"name": "pmaxval",
1997+
"type": "LESS THAN",
1998+
"expr": "MAXVALUE",
1999+
"subpartitions": null,
2000+
"options": {
2001+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
2002+
"options": []
2003+
}
2004+
}
2005+
],
17412006
"unknown": []
17422007
}
17432008
],

tests/data/parser/parseAlterTablePartitionByRange2.out

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,42 @@
467467
"2": "PARTITION BY"
468468
}
469469
},
470-
"field": " RANGE (MONTH(departure_date)) ( PARTITION p01 VALUES LESS THAN (02) , PARTITION pmaxval VALUES LESS THAN MAXVALUE )",
471-
"partitions": null,
470+
"field": " RANGE (MONTH(departure_date)) ",
471+
"partitions": [
472+
{
473+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
474+
"isSubpartition": false,
475+
"name": "p01",
476+
"type": "LESS THAN",
477+
"expr": {
478+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
479+
"database": null,
480+
"table": null,
481+
"column": null,
482+
"expr": "(02)",
483+
"alias": null,
484+
"function": null,
485+
"subquery": null
486+
},
487+
"subpartitions": null,
488+
"options": {
489+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
490+
"options": []
491+
}
492+
},
493+
{
494+
"@type": "PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition",
495+
"isSubpartition": false,
496+
"name": "pmaxval",
497+
"type": "LESS THAN",
498+
"expr": "MAXVALUE",
499+
"subpartitions": null,
500+
"options": {
501+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
502+
"options": []
503+
}
504+
}
505+
],
472506
"unknown": []
473507
}
474508
],

0 commit comments

Comments
 (0)