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

JSON Support 2 #108

Merged
merged 9 commits into from Jun 19, 2019

Conversation

Projects
None yet
2 participants
@jwoertink
Copy link
Member

commented Jun 15, 2019

This replaces #48 with some updates

  • ensure this runs on crystal 0.29.0
  • fixes a regression where setting value of anything other than String was ~10x slower
  • Puts a type restriction back in place on ColumnDefaultType.

One thing to note about this type restriction is that in pr 48 it was set to Object, this meant you could set default values on json columns super easy like default: {"number" => 1}. That was nice, but it also meant you could set pretty much anything there like default: HTTP::Params since as long as it was of type Object, it would work.

Eventually I would like to open this up, but in keeping with the type safe tradition, we can start with a rough version, and then slowly improve it over time.

@paulcsmith
Copy link
Member

left a comment

This looks really good/close.

I'd love to do another PR that adds some method to the criteria for JSON specific queries! Like contains, looking in keys, etc. That'd be sweet. But can definitely come later :)

Show resolved Hide resolved .gitignore Outdated
Show resolved Hide resolved spec/json_column_spec.cr Outdated
Show resolved Hide resolved spec/json_column_spec.cr
Show resolved Hide resolved src/avram/form.cr Outdated
Show resolved Hide resolved src/avram/migrator/column_default_helpers.cr Outdated
Show resolved Hide resolved src/avram/query_builder.cr Outdated

@paulcsmith paulcsmith referenced this pull request Jun 16, 2019

Closed

Jsonb support #48

@paulcsmith
Copy link
Member

left a comment

Looks great! :D

@paulcsmith
Copy link
Member

left a comment

Actually I just realized I don’t think we have any specs for querying Json. Could you add some specs for stuff like equals?

@paulcsmith

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

I don't get notified for updates/force pushes so can you ping me when you're ready for me to take another look?

@jwoertink

This comment has been minimized.

Copy link
Member Author

commented Jun 19, 2019

Weird. Yeah, I'm getting ready to work on this now, so it'll be here in a bit.

@jwoertink

This comment has been minimized.

Copy link
Member Author

commented Jun 19, 2019

@paulcsmith this adds a simple example on doing a where query with the json. I'll do a new PR to add in fancy query with json.

@paulcsmith

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

Looks great! Just needs a rebase and then I'll merge it in!

@jwoertink

This comment has been minimized.

Copy link
Member Author

commented Jun 19, 2019

@paulcsmith nothing to rebase.

@paulcsmith

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

Hmm looks like there is because I cannot merge
Screen Shot 2019-06-19 at 1 14 29 PM

Maybe you need to pull master first?

@jwoertink

This comment has been minimized.

Copy link
Member Author

commented Jun 19, 2019

Screen Shot 2019-06-19 at 10 17 25 AM

[10:11AM] avram (pr48)$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 13 commits.
  (use "git push" to publish your local commits)
[10:12AM] avram (master)$ git fetch upstream
[10:12AM] avram (master)$ git merge upstream/master
Already up to date.
[10:12AM] avram (master)$ git checkout pr48
Switched to branch 'pr48'
[10:12AM] avram (pr48)$ git merge master
Already up to date.

I'm not great at git. Maybe I'm missing something?

@paulcsmith

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

Ok...maybe GitHub is having issues lol. Because I still see that message that there are conflicts. Can you go ahead and merge it since I can't 🤣

@jwoertink jwoertink merged commit 5d7a509 into master Jun 19, 2019

2 checks passed

Travis CI - Branch Build Passed
Details
Travis CI - Pull Request Build Passed
Details

@jwoertink jwoertink deleted the pr48 branch Jun 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.