PyDBML icon indicating copy to clipboard operation
PyDBML copied to clipboard

Trailing comma in generated SQL for DBML enums

Open ralfschulze opened this issue 10 months ago • 1 comments

When converting a DBML enum to sql, the last entry of the generated CREATE TYPE statement has a trailing comma, which must not be there for PostgreSQL (see https://www.postgresql.org/docs/current/sql-createtype.html). Executing this statements fails with an error.

Example:

enum test_enum {
  valA
  valB
}

to sql

>>> from pydbml import PyDBML
>>> from pathlib import Path
>>> parsed = PyDBML(Path('test.dbml'))
>>> print(parsed.sql)
CREATE TYPE "test_enum" AS ENUM (
  'valA',
  'valB',
);

It should be

CREATE TYPE "test_enum" AS ENUM (
  'valA',
  'valB'
);

ralfschulze avatar Feb 13 '25 14:02 ralfschulze

Thanks for the report! Fixed in 1.1.4

Vanderhoof avatar Feb 14 '25 12:02 Vanderhoof