BESSER icon indicating copy to clipboard operation
BESSER copied to clipboard

Attribute named "ID" causes error in SQL alchemy generator

Open Aran30 opened this issue 1 year ago • 1 comments

If a model contains a class with an attribute named "ID", this will generate sql alchemy code containing an error. The problem stems from the sql alchemy generator always adding a column named "id" as a primary key, thus leading to a table having two columns named ID. The sql alchemy generator needs to do an additional check for attributes called "id".

Aran30 avatar May 02 '24 09:05 Aran30

We should also add a configuration property to configure whether we want to generate these ID fields for every class or not (I think we already have something similar for another generator)

jcabot avatar May 04 '24 04:05 jcabot

This issue is now fixed. If a model contains a class with an attribute named id, that field will be used as the table's primary key. Otherwise, a default id field will be created for the table.

Additionally, if an attribute of a class is marked as is_id, that field will be set as the primary key of the table.

ivan-alfonso avatar Mar 17 '25 15:03 ivan-alfonso