[DBIx-Class-Devel] [dbsrgits/sql-translator] Error parsing Oracle SQL with CURRENT_TIMESTAMP (Issue #141)
hazardv
notifications at github.com
Wed Aug 10 16:21:49 GMT 2022
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:
``` perl
#!/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
``` SQL
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.
--
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/sql-translator/issues/141
You are receiving this because you are subscribed to this thread.
Message ID: <dbsrgits/sql-translator/issues/141 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20220810/6df85fb6/attachment.htm>
More information about the DBIx-Class-Devel
mailing list