From b4b3c42f9038b8f1d2040ccf0ec16a304e358d13 Mon Sep 17 00:00:00 2001 From: Nicolas Giraud Date: Thu, 30 Jan 2025 10:30:58 +0100 Subject: [PATCH] Fix #610 and impacted unit tests, evolving the expectations. --- src/Components/AlterOperation.php | 2 ++ tests/data/parser/parseAlter14.out | 26 +++++++++---------- .../parser/parseAlterTableAddUniqueKey1.out | 26 +++++++++---------- .../parser/parseAlterTableAddUniqueKey2.out | 26 +++++++++---------- tests/data/parser/parsephpMyAdminExport1.out | 26 +++++++++---------- 5 files changed, 50 insertions(+), 56 deletions(-) diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php index fcd40c32..4264f03f 100644 --- a/src/Components/AlterOperation.php +++ b/src/Components/AlterOperation.php @@ -146,6 +146,8 @@ class AlterOperation extends Component 2, 'var', ], + 'UNIQUE' => 2, + 'UNIQUE KEY' => 2, 'CHARACTER SET' => 3, 'TO' => [ diff --git a/tests/data/parser/parseAlter14.out b/tests/data/parser/parseAlter14.out index a8eb1149..51c9699c 100644 --- a/tests/data/parser/parseAlter14.out +++ b/tests/data/parser/parseAlter14.out @@ -325,24 +325,22 @@ "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", "options": { - "1": "ADD" + "1": "ADD", + "2": "UNIQUE KEY" } }, - "field": null, + "field": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "database": null, + "table": null, + "column": "functional_index", + "expr": "`functional_index`", + "alias": null, + "function": null, + "subquery": null + }, "partitions": null, "unknown": [ - { - "@type": "@10" - }, - { - "@type": "@11" - }, - { - "@type": "@12" - }, - { - "@type": "@13" - }, { "@type": "@14" }, diff --git a/tests/data/parser/parseAlterTableAddUniqueKey1.out b/tests/data/parser/parseAlterTableAddUniqueKey1.out index 00f6540c..074879e9 100644 --- a/tests/data/parser/parseAlterTableAddUniqueKey1.out +++ b/tests/data/parser/parseAlterTableAddUniqueKey1.out @@ -217,24 +217,22 @@ "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", "options": { - "1": "ADD" + "1": "ADD", + "2": "UNIQUE KEY" } }, - "field": null, + "field": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "database": null, + "table": null, + "column": "name_of_the_unique_constraint", + "expr": "name_of_the_unique_constraint", + "alias": null, + "function": null, + "subquery": null + }, "partitions": null, "unknown": [ - { - "@type": "@10" - }, - { - "@type": "@11" - }, - { - "@type": "@12" - }, - { - "@type": "@13" - }, { "@type": "@14" }, diff --git a/tests/data/parser/parseAlterTableAddUniqueKey2.out b/tests/data/parser/parseAlterTableAddUniqueKey2.out index f2e2a5a0..bcd766b6 100644 --- a/tests/data/parser/parseAlterTableAddUniqueKey2.out +++ b/tests/data/parser/parseAlterTableAddUniqueKey2.out @@ -217,24 +217,22 @@ "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", "options": { - "1": "ADD" + "1": "ADD", + "2": "UNIQUE" } }, - "field": null, + "field": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "database": null, + "table": null, + "column": "name_of_the_unique_constraint", + "expr": "name_of_the_unique_constraint", + "alias": null, + "function": null, + "subquery": null + }, "partitions": null, "unknown": [ - { - "@type": "@10" - }, - { - "@type": "@11" - }, - { - "@type": "@12" - }, - { - "@type": "@13" - }, { "@type": "@14" }, diff --git a/tests/data/parser/parsephpMyAdminExport1.out b/tests/data/parser/parsephpMyAdminExport1.out index b78796fd..786d792b 100644 --- a/tests/data/parser/parsephpMyAdminExport1.out +++ b/tests/data/parser/parsephpMyAdminExport1.out @@ -5401,24 +5401,22 @@ "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", "options": { - "1": "ADD" + "1": "ADD", + "2": "UNIQUE KEY" } }, - "field": null, + "field": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "database": null, + "table": null, + "column": "idServer", + "expr": "`idServer`", + "alias": null, + "function": null, + "subquery": null + }, "partitions": null, "unknown": [ - { - "@type": "@394" - }, - { - "@type": "@395" - }, - { - "@type": "@396" - }, - { - "@type": "@397" - }, { "@type": "@398" },