genna icon indicating copy to clipboard operation
genna copied to clipboard

Not Generating Model Fields for "Belongs To" Relationships

Open lsnow99 opened this issue 5 years ago • 0 comments

I have a schema and relationship defined as follows:

Table chat_event: id (bigint)

Table message:

id   (bigint)
id_chat_event   (bigint, fk, uq, nn)

So a chat_event Belongs To a message, at least in the way I've defined my schema. When I run Genna, it outputs a struct for message that includes a reference to ChatEvent like so:

IdChatEventRel *ChatEvent `pg:"fk:id_chat_event"`

However, ChatEvent does not have any reference to message.

This is causing a problem, because I am trying to query using go-pg all chat_events in a conversation, and ideally each chat_event would have a *Message field that is populated. However, ChatEvent structs as generated by genna currently do not seem to contain a *Message field.

The command I am using is: ~/go/bin/genna model -c postgresql://localhost/mydb?sslmode=disable -f -g 9 -o model/schema.go

If you need more details, I may be able to provide them over a private channel, or maybe create a generic example.

Thank you for your work, Genna has been very helpful to my projects.

lsnow99 avatar May 17 '20 04:05 lsnow99