diff options
author | Prathamesh Sonpatki <csonpatki@gmail.com> | 2016-01-18 11:29:36 +0530 |
---|---|---|
committer | Prathamesh Sonpatki <csonpatki@gmail.com> | 2016-01-18 14:39:50 +0530 |
commit | ad08072249f85732abe4de408a0316c6b7bfaa99 (patch) | |
tree | c1f5bf0d042fe821c735690b0ce93b04d7c5af82 /guides | |
parent | d14db3700dc921ea5642403f81657776cc0a19fa (diff) | |
download | rails-ad08072249f85732abe4de408a0316c6b7bfaa99.tar.gz rails-ad08072249f85732abe4de408a0316c6b7bfaa99.tar.bz2 rails-ad08072249f85732abe4de408a0316c6b7bfaa99.zip |
Explain how HStore columns can be queried [ci skip]
- Fixes #22876.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_record_postgresql.md | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/guides/source/active_record_postgresql.md b/guides/source/active_record_postgresql.md index b592209d4b..68c6a77882 100644 --- a/guides/source/active_record_postgresql.md +++ b/guides/source/active_record_postgresql.md @@ -84,6 +84,7 @@ Book.where("array_length(ratings, 1) >= 3") ### Hstore * [type definition](http://www.postgresql.org/docs/current/static/hstore.html) +* [functions and operators](http://www.postgresql.org/docs/current/static/hstore.html#AEN167712) NOTE: You need to enable the `hstore` extension to use hstore. @@ -108,6 +109,9 @@ profile.settings # => {"color"=>"blue", "resolution"=>"800x600"} profile.settings = {"color" => "yellow", "resolution" => "1280x1024"} profile.save! + +Profile.where("settings->'color' = ?", "yellow") +#=> #<ActiveRecord::Relation [#<Profile id: 1, settings: {"color"=>"yellow", "resolution"=>"1280x1024"}>]> ``` ### JSON |