simple-ddl-parser icon indicating copy to clipboard operation
simple-ddl-parser copied to clipboard

Parser not working when double apostrophes are used inside of a comment (escaped apostrophe)

Open devxor opened this issue 3 years ago • 2 comments

Describe the bug In the SNOWFLAKE database, when you are using an apostrophe in a comment, the apostrophe is escaped with another apostrophe like:

  • comment on a field level is "Grouping of hierarchy L1's.". Is what you see with DESC TABLE...
  • in DDL is like "Grouping of hierarchy L1''s."

I have tested the parser and it seems, that this double apostrophes in comments are making issues and the parser returns an empty list or in case if there is a PK constraint in DDL, it returns a list with PK only - no columns etc, nothing more is returned.

To Reproduce Please try to parse the below DDL statement:

create or replace table MYTABLE (
    FIELD_1 NUMBER(38, 0) NOT NULL COMMENT 'some comment.',
    FIELD_2 VARCHAR(250) COMMENT 'some comment with apostrophes - grouping of hierarchy L1''s',
);

Expected behavior DDL parsed.

devxor avatar Oct 31 '22 15:10 devxor

@devxor I know about this issue))) but tried to ignore it too much as possible. It's hard to fix because of how parser identify a strings with quotes, I will try to figure out how to fix it with less pain

xnuinside avatar Oct 31 '22 16:10 xnuinside

@xnuinside thx! For my use case I don't care about comments, so I will use a workaround of simply removing double apostrophes '' from the DDL and the parser will still work. Of course it's not a solution for you. People would probably like to see their comments with apostrophes :).

devxor avatar Nov 04 '22 09:11 devxor