We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Parsing a CREATE TABLE statement fails if a column has a default of NOW().
CREATE TABLE
NOW()
SQLFluff should be able to parse the valid, executable SQL and report on any style guide violations it finds.
Instead, SQLFluff throws a parse error:
Line 1, Position 1: Found unparsable section: 'CREATE TABLE a ( t TIMESTAMP DEFAULT NOW...'
With default-timestamp.sql as
default-timestamp.sql
CREATE TABLE a ( t TIMESTAMP DEFAULT NOW() );
running SQLFluff returns a parse error:
$ sqlfluff parse --verbose --ignore-local-config --dialect mysql default-timestamp.sql ==== sqlfluff ==== sqlfluff: 0.11.0 python: 3.8.10 implementation: cpython dialect: mysql verbosity: 1 templater: jinja === [ path: default-timestamp.sql ] === [L: 1, P: 1] |file: [L: 1, P: 1] | statement: [L: 1, P: 1] | unparsable: !! Expected: 'StatementSegment' [L: 1, P: 1] | raw: 'CREATE' [L: 1, P: 7] | whitespace: ' ' [L: 1, P: 8] | raw: 'TABLE' [L: 1, P: 13] | whitespace: ' ' [L: 1, P: 14] | raw: 'a' [L: 1, P: 15] | whitespace: ' ' [L: 1, P: 16] | bracketed: [L: 1, P: 16] | start_bracket: '(' [L: 1, P: 17] | whitespace: ' ' [L: 1, P: 18] | raw: 't' [L: 1, P: 19] | whitespace: ' ' [L: 1, P: 20] | raw: 'TIMESTAMP' [L: 1, P: 29] | whitespace: ' ' [L: 1, P: 30] | raw: 'DEFAULT' [L: 1, P: 37] | whitespace: ' ' [L: 1, P: 38] | raw: 'NOW' [L: 1, P: 41] | bracketed: [L: 1, P: 41] | start_bracket: '(' [L: 1, P: 42] | end_bracket: ')' [L: 1, P: 43] | whitespace: ' ' [L: 1, P: 44] | end_bracket: ')' [L: 1, P: 45] | statement_terminator: ';' [L: 1, P: 46] | newline: '\n' ==== parsing violations ==== L: 1 | P: 1 | PRS | Line 1, Position 1: Found unparsable section: 'CREATE TABLE a ( t | TIMESTAMP DEFAULT NOW...'
MySQL
sqlfluff, version 0.11.0 Python 3.8.10
All defaults
The text was updated successfully, but these errors were encountered:
NOW
Thanks for the quick fix, @tunetheweb, and the quick review by @barrywhart!
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Search before asking
What Happened
Parsing a
CREATE TABLE
statement fails if a column has a default ofNOW()
.Expected Behaviour
SQLFluff should be able to parse the valid, executable SQL and report on any style guide violations it finds.
Observed Behaviour
Instead, SQLFluff throws a parse error:
How to reproduce
With
default-timestamp.sql
asrunning SQLFluff returns a parse error:
Dialect
MySQL
Version
sqlfluff, version 0.11.0
Python 3.8.10
Configuration
All defaults
Are you willing to work on and submit a PR to address the issue?
Code of Conduct
The text was updated successfully, but these errors were encountered: