Skip to content
New issue

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

Don't fail on dot within schema #71

Open
milesgranger opened this issue Aug 16, 2021 · 0 comments · May be fixed by #72
Open

Don't fail on dot within schema #71

milesgranger opened this issue Aug 16, 2021 · 0 comments · May be fixed by #72

Comments

@milesgranger
Copy link

milesgranger commented Aug 16, 2021

Hello there!
Thanks for a great lib, seems to work well.

One issue I've found, is if a schema has a dot in the schema (albeit annoyingly, but no control over naming), parsing will fail.

Minimal example:

from ddlparse import DdlParse

ddl = """ 
create table "foo.bar"."bazz" (
    id int
);
"""
DdlParse(ddl).parse()  # pyparsing.ParseException
DdlParse(ddl.replace('foo.bar', 'foo_bar')).parse()  # okay.

Exception:

pyparsing.ParseException: Expected {Suppress:({"--" Re:('.+')}) | {Suppress:("CREATE") ["TEMP"] Suppress:("TABLE") [Suppress:("IF NOT EXISTS")] [{Suppress:("") | Suppress:(""")}] [{W:(ABCD...) [{Suppress:("") | Suppress:(""")}] Suppress:(".") [{Suppress:("") | Suppress:(""")}]}] W:(ABCD...) [{Suppress:("") | Suppress:(""")}] Suppress:("(") {{{{{Suppress:({"--" Re:('.+')}) | Suppress:({"KEY" W:(ABCD...)})} | Group:({[{{{Suppress:("CONSTRAINT") [{Suppress:("") | Suppress:(""")}]} W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}] {{{{{{{{{{"PRIMARY KEY" ^ "UNIQUE"} ^ "UNIQUE KEY"} ^ "NOT NULL"} [{Suppress:("") | Suppress:(""")}]} [W:(ABCD...)]} [{Suppress:("") | Suppress:(""")}]} Suppress:("(")} Group:({{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]} [, {{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}]...)} Suppress:(")")} | {{{{"FOREIGN KEY" Suppress:("(")} Group:({{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]} [, {{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}]...)} Suppress:(")")} [{{{{{{{{{Suppress:("REFERENCES") [{Suppress:("") | Suppress:(""")}]} W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]} Suppress:("(")} Group:({{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]} [, {{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}]...)} Suppress:(")")} [{"MATCH" W:(ABCD...)}]} [{{"ON" "DELETE"} {{{"RESTRICT" | "CASCADE"} | "SET NULL"} | "NO ACTION"}}]} [{{"ON" "UPDATE"} {{{"RESTRICT" | "CASCADE"} | "SET NULL"} | "NO ACTION"}}]}]}}})} | Group:({{{{{{{Suppress:("") | Suppress:(""")} W:(ABCD...)} {Suppress:("") | Suppress:(""")}} ^ {{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}} Group:({{{Group:({W:(ABCD...) [{{{"WITHOUT TIME ZONE" ^ "WITH TIME ZONE"} ^ "PRECISION"} ^ "VARYING"}]}) [{{{Suppress:("(") Re:('[\d\]+\s,\s\d*')} [{"CHAR" | "BYTE"}]} Suppress:(")")}]} ["UNSIGNED"]} ["ZEROFILL"]})} [W:([])]} [{Re:('(?!--)') Group:({{{{{{{{[Re:('\b(?:NOT\s+)?NULL?\b')] & [Re:('\bAUTO_INCREMENT\b')]} & [Re:('\b(UNIQUE|PRIMARY)(?:\s+KEY)?\b')]} & [Re:('\bDEFAULT\b\s+(?:((?:[A-Za-z0-9_\.\'\" -\{\}]|[^\\x01-\\x7E])\:\:(?:character varying)?[A-Za-z0-9\[\]]+)|(?:\')((?:\\\'|[^\\\']|,)+)(?:\')|(?:\")((?:\\\"|[^\\"]|,)+)(?:\")|([^,\\s]+))')]} & [Re:('\bCOMMENT\b\s+(\'(\\\'|[^\\\']|,)+\'|\"(\\\"|[^\\"]|,)+\"|[^,\\s]+)')]} & [Re:('\bENCODE\s+[A-Za-z0-9]+\b')]} & ["DISTKEY"]} & ["SORTKEY"]} & [{Suppress:("CHARACTER SET") W:(ABCD...)}]})}]})} | Suppress:({"--" Re:('.+')})}}... [, {{{{{Suppress:({"--" Re:('.+')}) | Suppress:({"KEY" W:(ABCD...)})} | Group:({[{{{Suppress:("CONSTRAINT") [{Suppress:("") | Suppress:(""")}]} W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}] {{{{{{{{{{"PRIMARY KEY" ^ "UNIQUE"} ^ "UNIQUE KEY"} ^ "NOT NULL"} [{Suppress:("") | Suppress:(""")}]} [W:(ABCD...)]} [{Suppress:("") | Suppress:(""")}]} Suppress:("(")} Group:({{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]} [, {{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}]...)} Suppress:(")")} | {{{{"FOREIGN KEY" Suppress:("(")} Group:({{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]} [, {{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}]...)} Suppress:(")")} [{{{{{{{{{Suppress:("REFERENCES") [{Suppress:("") | Suppress:(""")}]} W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]} Suppress:("(")} Group:({{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]} [, {{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}]...)} Suppress:(")")} [{"MATCH" W:(ABCD...)}]} [{{"ON" "DELETE"} {{{"RESTRICT" | "CASCADE"} | "SET NULL"} | "NO ACTION"}}]} [{{"ON" "UPDATE"} {{{"RESTRICT" | "CASCADE"} | "SET NULL"} | "NO ACTION"}}]}]}}})} | Group:({{{{{{{Suppress:("") | Suppress:(""")} W:(ABCD...)} {Suppress:("") | Suppress:(""")}} ^ {{[{Suppress:("") | Suppress:(""")}] W:(ABCD...)} [{Suppress:("") | Suppress:(""")}]}} Group:({{{Group:({W:(ABCD...) [{{{"WITHOUT TIME ZONE" ^ "WITH TIME ZONE"} ^ "PRECISION"} ^ "VARYING"}]}) [{{{Suppress:("(") Re:('[\d\]+\s*,\s\d*')} [{"CHAR" | "BYTE"}]} Suppress:(")")}]} ["UNSIGNED"]} ["ZEROFILL"]})} [W:([])]} [{Re:('(?!--)') Group:({{{{{{{{[Re:('\b(?:NOT\s+)?NULL?\b')] & [Re:('\bAUTO_INCREMENT\b')]} & [Re:('\b(UNIQUE|PRIMARY)(?:\s+KEY)?\b')]} & [Re:('\bDEFAULT\b\s+(?:((?:[A-Za-z0-9_\.\'\" -\{\}]|[^\\x01-\\x7E])*\:\:(?:character varying)?[A-Za-z0-9\[\]]+)|(?:\')((?:\\\'|[^\\\']|,)+)(?:\')|(?:\")((?:\\\"|[^\\"]|,)+)(?:\")|([^,\\s]+))')]} & [Re:('\bCOMMENT\b\s+(\'(\\\'|[^\\\']|,)+\'|\"(\\\"|[^\\"]|,)+\"|[^,\\s]+)')]} & [Re:('\bENCODE\s+[A-Za-z0-9]+\b')]} & ["DISTKEY"]} & ["SORTKEY"]} & [{Suppress:("CHARACTER SET") W:(ABCD...)}]})}]})} | Suppress:({"--" Re:('.+')})}}...]...}}, found '.' (at char 22), (line:1, col:23)

@milesgranger milesgranger linked a pull request Aug 16, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant