SI-Gen / jportal2

JPortal2 is the newest version of the JPortal SI-file based generator
MIT License
11 stars 10 forks source link

PostgreSQL UID support #199

Open lacy-alistair-bbd opened 1 year ago

lacy-alistair-bbd commented 1 year ago

Hi team

Using the UID column type for PostgreSQL generates the following:

SI

TABLE service_pack
    id                      UID
    pack                    CHAR(20) NOT NULL

DDL

CREATE TABLE servcat.service_pack
( id unknown
, pack varchar(20)
![Capture](https://github.com/SI-Gen/jportal2/assets/99320393/52847fc2-c0fa-4a67-922a-e1c9316259ee)

);

The generated Python code also needs editing as it does not import the relevant String type

Capture

KeeganOP commented 1 year ago

Types for postgres can be found: https://github.com/SI-Gen/jportal2/blob/develop/src/main/java/bbd/jportal2/generators/PostgresDDL.java#L349

lacy-alistair-bbd commented 1 year ago

Does the documentation need to be updated to identify which types can be used with which databases?

Edit: I did check the types on the template. We're just not aware if UID is missing as an oversight or there is no intention to support it

KeeganOP commented 1 year ago

Documentation probably needs to be update. PR's welcome.

As for why now UID is supported in postgres i see no reason why it cant be supported. @dieterrosch your thoughts?

dieterrosch commented 1 year ago

It can be added.It hasn't been used thus far because historically using UUID's as PK's for database were a bad idea - for 99% of use cases sequences are/were better.

In terms of the String thing - that is very strange - we use that template in tons places and it works. @lacy-alistair-bbd What version of the template are you using? (Put another way, please send me the JPortal command line you're using?).

lacy-alistair-bbd commented 1 year ago

The example it's self was more indicative, Our use case it not necessarily as the PK, but more a tracking identifier that gets pushed to a downstream system

Our command line it: docker run --rm -v .:/serviceroot ghcr.io/si-gen/jportal2:1.10.5 \ --inputdir=/serviceroot/src/sql/si \ --builtin-generator PostgresDDL:/serviceroot/src/sql/ddl \ --template-generator SQLAlchemy:/serviceroot/src/app/data \ --download-template "SQLAlchemy:https://github.com/SI-Gen/jportal2-generator-vanguard-sqlalchemy/archive/refs/tags/2.5.zip|stripBaseDir"