mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
use correct operator in query based on JSON document
This commit is contained in:
parent
a2f8377d1d
commit
6d988e2a29
1 changed files with 2 additions and 1 deletions
|
@ -132,7 +132,8 @@ event = Event.first
|
|||
event.payload # => {"kind"=>"user_renamed", "change"=>["jack", "john"]}
|
||||
|
||||
## Query based on JSON document
|
||||
Event.where("payload->'kind' = ?", "user_renamed")
|
||||
# The -> operator returns the original JSON type (which might be an object), whereas ->> returns text
|
||||
Event.where("payload->>'kind' = ?", "user_renamed")
|
||||
```
|
||||
|
||||
### Range Types
|
||||
|
|
Loading…
Reference in a new issue