Skip to content

Commit

Permalink
Handle drop constraint (doableware#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raznak authored and nesdis committed Nov 18, 2018
1 parent 4b485d7 commit e40f1df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions djongo/sql2mongo/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,19 +555,25 @@ def _drop(self, tok_id):

while tok_id is not None:
if tok.match(tokens.Keyword, (
'COLUMN', 'CASCADE'
'CASCADE'
)):
pass
elif isinstance(tok, Identifier):
self._iden_name = tok.get_name()
elif tok.match(tokens.Keyword, 'CONSTRAINT'):
self.execute = self._drop_constraint
elif tok.match(tokens.Keyword, 'COLUMN'):
self.execute = self._drop_column
else:
raise NotImplementedError

tok_id, tok = sm.token_next(tok_id)

self.execute = self._drop_column
return tok_id

def _drop_constraint(self):
self.db_ref[self.left_table].drop_index(self._iden_name)

def _drop_column(self):
self.db_ref[self.left_table].update(
{},
Expand Down

0 comments on commit e40f1df

Please sign in to comment.