Skip to content

Allow explicit FK fields for inverse relations #237

Open
@josephbuchma

Description

@josephbuchma

From readme:

Foreign keys do not have to be in the model, they are automagically managed underneath by kallax.

AFAICT there is no way to get fk value without querying relation. And when I include foreign key to struct, kallax generates invalid code.

type Post struct {
  kallax.Model
  AuthorID int64
  Author *User `fk:",inverse"`
  // ...
}

Kallax generates duplicate switch statement cases for "author_id" field in func (r *Post) ColumnAddress and func (r *Post) Value methods.

UPDATE
And by the way, how to load "inverse" relations for object without re-querying everything using With<Relation> methods ? This "virtual columns" seem to just add more complexity and inconveniences without providing reasonable value.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions