Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreign key in embedded struct #293

Open
sywesk opened this issue Sep 8, 2018 · 1 comment
Open

Foreign key in embedded struct #293

sywesk opened this issue Sep 8, 2018 · 1 comment

Comments

@sywesk
Copy link

sywesk commented Sep 8, 2018

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

@roobre
Copy link
Contributor

roobre commented Oct 4, 2018

Is the User model being recognized and used by kallax?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants