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

Comments / references

Open erwin-frohsinn opened this issue 1 year ago • 0 comments

Describe the bug Actually, more of an annoyance instead of a bug.

CREATE TABLE pole.t_spiel (
	id varchar(10) NOT NULL, -- Comment 0 
	refprodid varchar(10) NOT NULL, -- Comment 1 // references is empty
	titel varchar(100) NOT NULL, -- Comment 2
	datum date NOT NULL,
	uhrzeit time NOT NULL, 
	dauer int4 NOT NULL, -- Comment 3, should be 5
	CONSTRAINT t_spiel_pk PRIMARY KEY (id),
        CONSTRAINT foreign_key_t_produktion FOREIGN KEY (refprodid) REFERENCES pole.t_produktion (id)
);

The above ddl demonstrates two issues:

  1. I would expect that the field references in the column describing refprodid would contain pole.t_produktion (id), but it is empty.

  2. The comments are all parsed but such, that the connection to the corresponding field is lost, because fields without comments are left out. Several ways to solve: a) create entries with empty strings, where no comment exists b) create a dictionary of comments instead, where the key is the field name and the value is the comment c) create a new field "comment" as part of the column (preferable in my opinion). Why do I need this? I do a postprocessing of the parsed structure in which I take the comments as hints for the users and additionally to qualify the fields for their presentation. Currently, I've programmed a workaround, but of course, I'd prefer if simply-ddl-parser would support this in the first place.

To Reproduce Parse with simple_ddl_parser

Desktop (please complete the following information):

OS: Kubuntu
Python 3.12
Postgres

erwin-frohsinn avatar Aug 17 '24 05:08 erwin-frohsinn