dbsrgits / sql-translator

SQL::Translator (SQLFairy)
http://sqlfairy.sourceforge.net/
82 stars 91 forks source link

SQL::Translator::Parser::Oracle fails to parse DROP statement #89

Open jgrg opened 7 years ago

jgrg commented 7 years ago

On line 137 of SQL::Translator::Parser::Oracle, the grammar rule:

drop : /drop/i WORD(s) NAME WORD(s?) ';'

fails to match if table names aren't surrounded with quotes because WORD(s) matches to the end and NAME has nothing left to match.

trentfisher commented 5 years ago

I just happened upon this problem. I boiled it down to this reproduction:

$  echo "drop table foo;" |sqlt -f Oracle -t SQLite
       ERROR (line 1): Invalid statement: Was expecting remark, or run, or
                       prompt, or create, or table comment, or comment on
                       table, or comment on column, or alter, or drop
Error: translate: Error with parser 'SQL::Translator::Parser::Oracle': Parse failed.

Replace "Oracle" with "SQLite" and it works.

Changing WORD(s) to WORD in the line noted previously made it work, though I'm not sure that's the correct solution.