xnuinside/simple-ddl-parser

Column comments containing `''` don't parse.

PBalsdon opened this issue · 2 comments

Describe the bug
Parsing fails where column comments contain a pair of single quotes, ''. This is used for column comments in snowflake to allow a single ' to appear in the definition.

To Reproduce
Parse the statement:

CREATE TABLE table (column_1 int comment 'This comment isn''t right')

Expected behavior
A standard parsing output:
Expected:

[{
  'alter': {},
  'checks': [],
  'clone': None,
  'columns': [{'check': None,
               'comment': "'This comment isn't right'",
               'default': None,
               'name': 'column_1',
               'nullable': True,
               'references': None,
               'size': None,
               'type': 'int',
               'unique': False}],
  'index': [],
  'partitioned_by': [],
  'primary_key': [],
  'primary_key_enforced': None,
  'schema': None,
  'table_name': 'table',
  'tablespace': None
}]

Screenshots
Instead, we get the output []

Version
Latest

Additional context
I know this is snowflake syntax. Perhaps it is also true for other dialects, I'm not sure.

@PBalsdon hi! Thanks for creating the issue, I added support for this #210 & test. It will be released in version 0.31.1 together with your PR.