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

Gorm Gotchas #20

Open
depado opened this issue Mar 19, 2018 · 4 comments
Open

Gorm Gotchas #20

depado opened this issue Mar 19, 2018 · 4 comments

Comments

@depado
Copy link
Owner

depado commented Mar 19, 2018

This is the comment issue for the Gorm Gotchas article.

@shackra
Copy link

shackra commented Sep 22, 2018

Hey, thanks for the article!

I was wondering how are you supposed to use Article and Tag if you declare them inside the migration, do you re-declare them outside of the migration or what is your approach?

@depado
Copy link
Owner Author

depado commented Sep 24, 2018

@shackra
Hey, thanks for the article!

I was wondering how are you supposed to use Article and Tag if you declare them inside the migration, do you re-declare them outside of the migration or what is your approach?

Hey :) Thanks for your feedback. You declare them both in your migration and in your model. This way, your migrations are not tied with your model.

@getmetorajesh
Copy link

getmetorajesh commented Mar 24, 2019

Not sure if it has changed with gorm version, but this,

MetaDataB postgres.Jsonb `gorm:"type:jsonb;"

seems to not work anymore.

MetaDataB json.RawMessage `gorm:"type:jsonb;"`

works

@depado
Copy link
Owner Author

depado commented Mar 25, 2019

Hey.
I'll give that a try when I'll have time, but at the time of writing this did work. I'm surprised that json.RawMessage would work. Under the hood, postgres.Jsonb is effectively a json.RawMessage but it also implements the sql.Scanner and driver.Valuer interfaces so that gorm can effectively use this type as you can see in the source code of Gorm
Thanks a lot for your feedback on my post!

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

No branches or pull requests

3 participants