-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental/json serializable columns (#695)
* Attempting to implement the json serializable. First spec passes, but it's super hacky * round two reverts some of the previous commit. Now using a column converter. Still needs lots more specs * reverting these changes because they're refactors and not really related to this PR. There's already enough noise. * use separate branch with json changes and we no longer need any patches * Adding the ability to query serializable columns * This line wasn't needed * Go back to original PG Shard, but use master now that Matthew's PR was merged
- Loading branch information
Showing
9 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class AddMetadataToBlobs::V20210703234151 < Avram::Migrator::Migration::V1 | ||
def migrate | ||
alter :blobs do | ||
add metadata : JSON::Any, default: JSON::Any.new({} of String => JSON::Any) | ||
add media : JSON::Any?, fill_existing_with: :nothing | ||
end | ||
end | ||
|
||
def rollback | ||
alter :blobs do | ||
remove :metadata | ||
remove :media | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
class BlobFactory < BaseFactory | ||
def initialize | ||
doc JSON::Any.new({"foo" => JSON::Any.new("bar")}) | ||
metadata(BlobMetadata.from_json({name: "Test", code: 4}.to_json)) | ||
media nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
class BlobMetadata | ||
include JSON::Serializable | ||
|
||
property name : String? | ||
property code : Int32? | ||
end | ||
|
||
class MediaMetadata | ||
include JSON::Serializable | ||
|
||
property image : String? | ||
end | ||
|
||
class Blob < BaseModel | ||
table do | ||
column doc : JSON::Any? | ||
column metadata : BlobMetadata, serialize: true | ||
column media : MediaMetadata?, serialize: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters