-
Notifications
You must be signed in to change notification settings - Fork 64
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
Experimental/json serializable columns #695
Conversation
… it's super hacky
…verter. Still needs lots more specs
require "db" | ||
require "pg" | ||
require "uuid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These had to be moved up so our patch to "pg" comes after the definition
…ted to this PR. There's already enough noise.
I am excited for this feature. I have been using json more and more these days. |
I think there might also be some query features we can add. |
@wontruefree Have any ideas for an API for query stuff using this? I know one that I'd like to do is some sort of "has_key?" type method. The json query stuff in postgres is pretty gnarly. Also related: #197 We could add this in and do a separate PR unless it's something minimal... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! This is a solid setup to play around with and see how it works
This is a `JSON::Serializable` column, as an alternative to the `UserOptions` model. Made possible by luckyframework/avram#695.
Fixes #691
This is an experimental draft to serializing json columns in to objects. In order to do this, it requires a patch to how the PG shard decodes JSON columns. @matthewmcgarvey submitted will/crystal-pg#232 as a means to fix that hack.
To use them, your migrations would implement the
JSON::Any
as they do now, so nothing changes there. This means existing columns don't need any sort of migration. In your model, you can continue to useJSON::Any
as is without changing anything. If you want to use the serialized column, you'll change the type fromJSON::Any
to your serializable object type, and then add the column optionserialize: true
.There's still a few questions left to answer: