I am making an application with Rails 5 rc1. Rails 5 support mysql 5.7 json datatype.
add_column :organizations, :external, :json
Suppose the value in this column is as follows:
+---------------------------+
| external |
+---------------------------+
| {"id": 10, "type": "mos"} |
+---------------------------+
To search a particular "id" and "type" in external column, I use the following query in mysql:
select external from organizations where JSON_CONTAINS(external,'{"id": 10, "type": "mos"}') ;
Now, I want to know, how to make the same query using rails. The following doesn't work:
Organization.where("JSON_CONTAINS(external,'{"id": 10, "type": "mos"}')")
Note: I cannot remove quotes around the json text as it is part of the query.