PyDBML icon indicating copy to clipboard operation
PyDBML copied to clipboard

PyDBML fails to parse Indexes with names

Open pierresouchay opened this issue 10 months ago • 0 comments

While working on https://github.com/holistics/dbml/pull/549

I discovered that PyDBML seems to fail if name is set on an index, here is a minimum example:

Table "alembic_version" {
  "version_num" "character varying(32)" [pk, not null]

Indexes {
  version_num [pk, name: 'alembic_version_pk']
}
}

According to the specification, the value name name: 'alembic_version_pk' should be used to set a name to the index if I am not mistaken

Here, it fails with the following error:

  File ".venv/lib/python3.12/site-packages/pydbml/parser/parser.py", line 61, in __new__
    return cls.parse(source)
           ^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/pydbml/parser/parser.py", line 77, in parse
    return parser.parse()
           ^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/pydbml/parser/parser.py", line 105, in parse
    self._syntax.parse_string(self.source, parseAll=True)
  File ".venv/lib/python3.12/site-packages/pyparsing/core.py", line 1200, in parse_string
    raise exc.with_traceback(None)
pyparsing.exceptions.ParseSyntaxException: Expected ']', found ','  (at char 109), (line:5, col:18)

pierresouchay avatar Apr 16 '24 08:04 pierresouchay