Skip to content

Commit

Permalink
Merge pull request #1717 from taozhi8833998/fix-alter-drop-key-mysql
Browse files Browse the repository at this point in the history
fix: alter table drop index with identified in mysql
  • Loading branch information
taozhi8833998 authored Dec 16, 2023
2 parents 0842556 + 3291809 commit 62e7191
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pegjs/mariadb.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ ALTER_DROP_KEY_INDEX
type: 'alter',
}
}
/ KW_DROP __ k:(('FOREIGN'i? __ KW_KEY) / (KW_INDEX)) __ c:ident_name {
/ KW_DROP __ k:(('FOREIGN'i? __ KW_KEY) / (KW_INDEX)) __ c:ident {
const resource = Array.isArray(k) ? 'key' : 'index'
return {
action: 'drop',
Expand Down
2 changes: 1 addition & 1 deletion pegjs/mysql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ ALTER_DROP_KEY_INDEX
type: 'alter',
}
}
/ KW_DROP __ k:(('FOREIGN'i? __ KW_KEY) / (KW_INDEX)) __ c:ident_name {
/ KW_DROP __ k:(('FOREIGN'i? __ KW_KEY) / (KW_INDEX)) __ c:ident {
const resource = Array.isArray(k) ? 'key' : 'index'
return {
action: 'drop',
Expand Down
9 changes: 8 additions & 1 deletion test/mysql-mariadb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,19 @@ describe('mysql', () => {
]
},
{
title: 'alter drop index or key',
title: 'alter drop index',
sql: [
'ALTER TABLE table_name DROP INDEX index_name',
'ALTER TABLE `table_name` DROP INDEX index_name'
]
},
{
title: 'alter drop key',
sql: [
'ALTER TABLE table_name DROP key `key_name`',
'ALTER TABLE `table_name` DROP KEY `key_name`'
]
},
]
SQL_LIST.forEach(sqlInfo => {
const { title, sql } = sqlInfo
Expand Down

0 comments on commit 62e7191

Please sign in to comment.