Skip to content

Commit 1c35fdc

Browse files
committed
Merge #441 - Fix #330 - Add KEY to CreateDefinition
Pull-request: #441 Fixes: #330 Signed-off-by: William Desportes <williamdes@wdes.fr>
2 parents 32e10ad + 0d37022 commit 1c35fdc

File tree

4 files changed

+199
-75
lines changed

4 files changed

+199
-75
lines changed

src/Components/CreateDefinition.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class CreateDefinition extends Component
5656
'var',
5757
],
5858
'AUTO_INCREMENT' => 3,
59+
'KEY' => 4,
5960
'PRIMARY' => 4,
6061
'PRIMARY KEY' => 4,
6162
'UNIQUE' => 4,

tests/data/parser/parseCreateTable13.out

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,72 @@
430430
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
431431
"options": {
432432
"1": "NOT NULL",
433-
"3": "AUTO_INCREMENT"
433+
"3": "AUTO_INCREMENT",
434+
"4": "KEY"
434435
}
435436
}
437+
},
438+
{
439+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
440+
"name": "make",
441+
"isConstraint": null,
442+
"type": {
443+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
444+
"name": "VARCHAR",
445+
"parameters": [
446+
"128"
447+
],
448+
"options": {
449+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
450+
"options": []
451+
}
452+
},
453+
"key": null,
454+
"references": null,
455+
"options": {
456+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
457+
"options": []
458+
}
459+
},
460+
{
461+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
462+
"name": "year",
463+
"isConstraint": null,
464+
"type": {
465+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
466+
"name": "INTEGER",
467+
"parameters": [],
468+
"options": {
469+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
470+
"options": []
471+
}
472+
},
473+
"key": null,
474+
"references": null,
475+
"options": {
476+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
477+
"options": []
478+
}
479+
},
480+
{
481+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
482+
"name": "mileage",
483+
"isConstraint": null,
484+
"type": {
485+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
486+
"name": "INTEGER",
487+
"parameters": [],
488+
"options": {
489+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
490+
"options": []
491+
}
492+
},
493+
"key": null,
494+
"references": null,
495+
"options": {
496+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
497+
"options": []
498+
}
436499
}
437500
],
438501
"with": null,
@@ -454,7 +517,7 @@
454517
}
455518
},
456519
"first": 0,
457-
"last": 24
520+
"last": 39
458521
}
459522
],
460523
"brackets": 0,
@@ -463,28 +526,6 @@
463526
},
464527
"errors": {
465528
"lexer": [],
466-
"parser": [
467-
[
468-
"A comma or a closing bracket was expected.",
469-
{
470-
"@type": "@20"
471-
},
472-
0
473-
],
474-
[
475-
"Unexpected beginning of statement.",
476-
{
477-
"@type": "@27"
478-
},
479-
0
480-
],
481-
[
482-
"Unrecognized statement type.",
483-
{
484-
"@type": "@31"
485-
},
486-
0
487-
]
488-
]
529+
"parser": []
489530
}
490531
}

tests/data/parser/parseCreateTable14.out

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,72 @@
411411
"options": {
412412
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
413413
"options": {
414-
"1": "NOT NULL"
414+
"1": "NOT NULL",
415+
"4": "KEY"
415416
}
416417
}
418+
},
419+
{
420+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
421+
"name": "make",
422+
"isConstraint": null,
423+
"type": {
424+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
425+
"name": "VARCHAR",
426+
"parameters": [
427+
"128"
428+
],
429+
"options": {
430+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
431+
"options": []
432+
}
433+
},
434+
"key": null,
435+
"references": null,
436+
"options": {
437+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
438+
"options": []
439+
}
440+
},
441+
{
442+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
443+
"name": "year",
444+
"isConstraint": null,
445+
"type": {
446+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
447+
"name": "INTEGER",
448+
"parameters": [],
449+
"options": {
450+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
451+
"options": []
452+
}
453+
},
454+
"key": null,
455+
"references": null,
456+
"options": {
457+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
458+
"options": []
459+
}
460+
},
461+
{
462+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
463+
"name": "mileage",
464+
"isConstraint": null,
465+
"type": {
466+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
467+
"name": "INTEGER",
468+
"parameters": [],
469+
"options": {
470+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
471+
"options": []
472+
}
473+
},
474+
"key": null,
475+
"references": null,
476+
"options": {
477+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
478+
"options": []
479+
}
417480
}
418481
],
419482
"with": null,
@@ -435,7 +498,7 @@
435498
}
436499
},
437500
"first": 0,
438-
"last": 22
501+
"last": 37
439502
}
440503
],
441504
"brackets": 0,
@@ -444,28 +507,6 @@
444507
},
445508
"errors": {
446509
"lexer": [],
447-
"parser": [
448-
[
449-
"A comma or a closing bracket was expected.",
450-
{
451-
"@type": "@18"
452-
},
453-
0
454-
],
455-
[
456-
"Unexpected beginning of statement.",
457-
{
458-
"@type": "@25"
459-
},
460-
0
461-
],
462-
[
463-
"Unrecognized statement type.",
464-
{
465-
"@type": "@29"
466-
},
467-
0
468-
]
469-
]
510+
"parser": []
470511
}
471512
}

tests/data/parser/parseCreateTable15.out

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,72 @@
430430
"options": {
431431
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
432432
"options": {
433-
"1": "NOT NULL"
433+
"1": "NOT NULL",
434+
"4": "KEY"
434435
}
435436
}
437+
},
438+
{
439+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
440+
"name": "make",
441+
"isConstraint": null,
442+
"type": {
443+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
444+
"name": "VARCHAR",
445+
"parameters": [
446+
"128"
447+
],
448+
"options": {
449+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
450+
"options": []
451+
}
452+
},
453+
"key": null,
454+
"references": null,
455+
"options": {
456+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
457+
"options": []
458+
}
459+
},
460+
{
461+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
462+
"name": "year",
463+
"isConstraint": null,
464+
"type": {
465+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
466+
"name": "INTEGER",
467+
"parameters": [],
468+
"options": {
469+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
470+
"options": []
471+
}
472+
},
473+
"key": null,
474+
"references": null,
475+
"options": {
476+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
477+
"options": []
478+
}
479+
},
480+
{
481+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
482+
"name": "mileage",
483+
"isConstraint": null,
484+
"type": {
485+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
486+
"name": "INTEGER",
487+
"parameters": [],
488+
"options": {
489+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
490+
"options": []
491+
}
492+
},
493+
"key": null,
494+
"references": null,
495+
"options": {
496+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
497+
"options": []
498+
}
436499
}
437500
],
438501
"with": null,
@@ -454,7 +517,7 @@
454517
}
455518
},
456519
"first": 0,
457-
"last": 24
520+
"last": 39
458521
}
459522
],
460523
"brackets": 0,
@@ -463,28 +526,6 @@
463526
},
464527
"errors": {
465528
"lexer": [],
466-
"parser": [
467-
[
468-
"A comma or a closing bracket was expected.",
469-
{
470-
"@type": "@20"
471-
},
472-
0
473-
],
474-
[
475-
"Unexpected beginning of statement.",
476-
{
477-
"@type": "@27"
478-
},
479-
0
480-
],
481-
[
482-
"Unrecognized statement type.",
483-
{
484-
"@type": "@31"
485-
},
486-
0
487-
]
488-
]
529+
"parser": []
489530
}
490531
}

0 commit comments

Comments
 (0)