fraenky8 / tables-to-go

convert your database tables to structs easily
MIT License
233 stars 42 forks source link

Not null enum columns return pointers #45

Closed ricardo-snyk closed 2 years ago

ricardo-snyk commented 2 years ago

Hey!

In postgres if I have a column as:

+--------------------------+--------------------------+-----------+
| Column                   | Type                     | Modifiers |
|--------------------------+--------------------------+-----------|
| rule_severity            | severity                 |  not null |

where severity is a type CREATE TYPE severity AS ENUM ('low', 'medium', 'high', 'critical');

tables-to-go will generate: RuleSeverity *string

I was expecting RuleSeverity string since we have a not null column.

I will see if I can have a PR for this (if this is simple!).

fraenky8 commented 2 years ago

Hi @ricardo-snyk, good catch!

Yes you are right, the default branch assumes it's a nullable-column. I played around with it a bit and would like to make (nullable) strings the default/fallback for unknown column types. If you don't mind I would like to take over from here and open a new PR with these modification and some slightly refactorings. Hope I can tackle it this weekend!

fraenky8 commented 2 years ago

@ricardo-snyk I opened https://github.com/fraenky8/tables-to-go/pull/47 - please check if it works for you. Tested on my side with MySQL and PG and works fine! 👍

ricardo-snyk commented 2 years ago

🥇 Works as expected!! 🚀