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
I would get an error trying to insert confirmed_rel and owner_address_rel: ERROR #42703 column "confirmed_rel" of relation "assets" does not exist
If it was a single foreign key, go-pg/pg ignores the foreign key field and only inserts the valid confirmed and owner_address. The specific check to deny filtering composite key is at https://github.com/go-pg/pg/blob/master/orm/table.go#L922
So my question is whether genna should generate composite foreign keys in a different way so inserting with the auto-generated data works out-of-box. For now I am explicitly adding sql:"-" so it doesn't save. Alternatively, maybe not generate at all, or generate them in a different way for go-pg/pg to recognize? Thanks for any suggestions.
The text was updated successfully, but these errors were encountered:
I've tried several ways to describe foreign keys with multiple fields and got no success. I'll write to go-pg author directly and ask him about that, but I think there no possibility to define such model.
Anyway, I've fixed some bugs I found while trying make this work :)
Hello, I have two tables with one composite foreign key referring to another
The simplified pg schema is
When using genna to generate separated models, I got one for
accounts
and one forassets
The issue is that if I insert
Asset
into pg usingI would get an error trying to insert
confirmed_rel
andowner_address_rel
:ERROR #42703 column "confirmed_rel" of relation "assets" does not exist
If it was a single foreign key, go-pg/pg ignores the foreign key field and only inserts the valid
confirmed
andowner_address
. The specific check to deny filtering composite key is at https://github.com/go-pg/pg/blob/master/orm/table.go#L922So my question is whether genna should generate composite foreign keys in a different way so inserting with the auto-generated data works out-of-box. For now I am explicitly adding
sql:"-"
so it doesn't save. Alternatively, maybe not generate at all, or generate them in a different way for go-pg/pg to recognize? Thanks for any suggestions.The text was updated successfully, but these errors were encountered: