When attempting to parse Oracle SQL where a column definition has a default value of CURRENT_TIMESTAMP the parser will fail with the following error:
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
translate: Error with parser 'SQL::Translator::Parser::Oracle': Parse failed.
You can recreate the error with the following script:
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use SQL::Translator;
my $translator = SQL::Translator->new(
# Print debug info
debug => 1,
# Print Parse::RecDescent trace
trace => 1,
# Don't include comments in output
no_comments => 0,
# Print name mutations, conflicts
show_warnings => 1,
# Add "drop table" statements
add_drop_table => 1,
# to quote or not to quote, thats the question
quote_identifiers => 1,
# Validate schema object
validate => 1,
# Make all table names CAPS in producers which support this option
format_table_name => sub {my $tablename = shift; return uc($tablename)},
# Null-op formatting, only here for documentation's sake
format_package_name => sub {return shift},
format_fk_name => sub {return shift},
format_pk_name => sub {return shift},
);
my $output = $translator->translate(
from => 'Oracle',
to => 'MySQL',
# Or an arrayref of filenames, i.e. [ $file1, $file2, $file3 ]
filename => "$FindBin::Bin/../db_versions/just_person_test.sql",
) or die $translator->error;
print $output;
just_person_test.sql contains the following
CREATE TABLE person (
id varchar2(32) NOT NULL,
added date DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
If you remove DEFAULT CURRENT_TIMESTAMP it will parse just fine.
When attempting to parse Oracle SQL where a column definition has a default value of CURRENT_TIMESTAMP the parser will fail with the following error:
You can recreate the error with the following script:
just_person_test.sql contains the following
If you remove
DEFAULT CURRENT_TIMESTAMP
it will parse just fine.