fraenky8 / tables-to-go

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

Treat UUIDs as strings #41

Closed stdinltd closed 2 years ago

fraenky8 commented 2 years ago

@stdinltd thanks for opening this PR.

Can you also provide at a unit test in the form of func TestRun_UUIDColumns(t *testing.T) to cover this new type? Check the existing ones for examples.

Thanks!

ricleal-fugue commented 2 years ago

Hey!

We are using tables-to-go in our project and I just stumble up on this PR.

Yes, it's PostgreSQL. If we have primary keys (that are never null) of type UUID, the tables-to-go generates sql.NullString (or *string) instead of string. If we have a db table:

+-----------------+--------------------------+-----------+
| Column          | Type                     | Modifiers |
|-----------------+--------------------------+-----------|
| id              | uuid                     |  not null |

The tables-to-go output ID sql.NullString / *string..... I think this PR corrects this to ID string ....

fraenky8 commented 2 years ago

Fixed by #42