Skip to content

Foreign key in embedded struct #293

@sywesk

Description

@sywesk

Hello,

I tried to embed a struct that contained a foreign key, but instead a getting a foreign key, the model got a jsonb field. For example, this code would trigger this problem :

type SoftDeleteMixin struct {
	Deleted   bool
	DeletedAt *time.Time
	DeletedBy *User `fk:"user_id,inverse"`
}

type Subject struct {
	kallax.Model `table:"subjects" pk:"id"`
	kallax.Timestamps
	SoftDeleteMixin

	[...]
}

Which results in this code being generated:

CREATE TABLE subjects (
	created_at timestamptz NOT NULL,
	updated_at timestamptz NOT NULL,
	deleted boolean NOT NULL,
	deleted_at timestamptz,
	deleted_by jsonb
);

Do you have an idea of what's happening here ?

Thank you,
Benjamin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions