bun icon indicating copy to clipboard operation
bun copied to clipboard

Add support for nested Relation

Open vmihailenco opened this issue 4 years ago • 4 comments

Instead of

q.Relation("Foo").Relation("Foo.Bar")

You should be able to write

q.Relation("Foo", func(q *SelectQuery) *SelectQuery {
    return q.Relation("Bar")
}).

vmihailenco avatar Sep 04 '21 10:09 vmihailenco

@vmihailenco I ran into this when trying to migration from go-pg. I have the statement:

Relation("Task.User.id")

And it now gives me an error in "bun":

Attachment does not have relation="Task.User.id"

This is a one to one to one relationship. Is this possible with bun?

wavded avatar Sep 10 '21 15:09 wavded

@wavded it should be (AFAIR it is the same in pg v10)

q = db.Relation("Task.User", func(q *SelectQuery) *SelectQuery {
    return q.Column("id")
})

vmihailenco avatar Sep 11 '21 06:09 vmihailenco

That works! Thx @vmihailenco

wavded avatar Sep 13 '21 14:09 wavded

@vmihailenco hey! Any progress on this issue?

metalrex100 avatar Jan 26 '22 19:01 metalrex100