You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type overriding does not work for uuid, causes import conflict #1984
Originally posted by utkarshod December 4, 2022
I want to override the google uuid but when I try type overriding, it does not replace the google uuid but merely adds the new one to the imports of the models.go:
"github.com/gofrs/uuid"
"github.com/google/uuid"
This causes the following import error:
internal/queries/models.go:13:2: uuid redeclared in this block
internal/queries/models.go:11:2: other declaration of uuid
I've tried version 1 (as following), version 2 and column overriding and yet I am unable to get the google uuid to stop being imported. Note: Type overriding works for me for another db type, just not uuid.
@mcdoker18 thanks so much for the response! That helped.
The issue was that in my schema, I had one uuid and one uuid NOT NULL. And the latter was getting assigned the google uuid (example), resulting in 2 different uuid imports in models.go.
But following your suggestion, I overrode both nullable and not nullable uuids like here, which solved the problem.
Activity
mcdoker18 commentedon Dec 4, 2022
Can you provide the reproducible example?
Because the type overriding works https://play.sqlc.dev/p/26d5866a44400ad7b1a183cc8b43e4ecb691e76274fed0f01d7711a386b635e7
If you need use both packages, you can specify package alias:
utkarshod commentedon Dec 4, 2022
@mcdoker18 thanks so much for the response! That helped.
The issue was that in my schema, I had one
uuidand oneuuid NOT NULL. And the latter was getting assigned the google uuid (example), resulting in 2 different uuid imports inmodels.go.But following your suggestion, I overrode both nullable and not nullable uuids like here, which solved the problem.