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
Merged

JSON Support 2 #108

merged 9 commits into from
Jun 19, 2019

Conversation

jwoertink
Copy link
Member

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.

Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

.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 Show resolved Hide resolved
@paulcsmith paulcsmith mentioned this pull request Jun 16, 2019
Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! :D

Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

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
Copy link
Member Author

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

@jwoertink
Copy link
Member Author

@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
Copy link
Member

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

@jwoertink
Copy link
Member Author

@paulcsmith nothing to rebase.

@paulcsmith
Copy link
Member

paulcsmith 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
Copy link
Member Author

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
Copy link
Member

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 🤣

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

Successfully merging this pull request may close these issues.

2 participants