Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop index incorrect syntax #49

Closed
isgroup-srl opened this issue Dec 21, 2016 · 5 comments
Closed

Drop index incorrect syntax #49

isgroup-srl opened this issue Dec 21, 2016 · 5 comments

Comments

@isgroup-srl
Copy link

There should not be an ON statement after DROP INDEX inside an ALTER TABLE query (http://dev.mysql.com/doc/refman/5.7/en/alter-table.html). This behavior is legit if the DROP INDEX is used as a standalone query (http://dev.mysql.com/doc/refman/5.7/en/drop-index.html).

ALTER TABLE `foo` ADD COLUMN `x` bigint(20) unsigned NOT NULL AFTER `id`, DROP INDEX `y` ON `foo` [..]

Should be:

ALTER TABLE `foo` ADD COLUMN `x` bigint(20) unsigned NOT NULL AFTER `id`, DROP INDEX `y` [..]
@cpd1992
Copy link

cpd1992 commented Dec 27, 2016

Can anybody repair this issue? Thanks a lot

@jacoryjin
Copy link
Contributor

schemaobject->index.py->class IndexSchema(object)->drop,

if self.name == 'PRIMARY':
return "DROP PRIMARY KEY"
else:
return "DROP INDEX %s ON %s" % (self.name, self.parent.name)

changed to:

if self.name == 'PRIMARY':
return "DROP PRIMARY KEY"
else:
return "DROP INDEX `%s``" % (self.name)

@mmatuson
Copy link
Owner

@jacoryjin if you can submit a PR, I'll merge it

@stephenreay
Copy link
Contributor

This should be fixed in mmatuson/SchemaObject#13

@stephenreay
Copy link
Contributor

@mmatuson any chance of getting the referenced PR above merged in (as it should fix this issue)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants