I have a table with a json column "contact_info", the structure of this column is usually as follows:
{
"telephones":[
{"telephone":54435345,"type":"landline"},
{"telephone":694823747,"type":"mobile"},
]
}
I want to find all rows with a specific phone. The only thing I found in json arrays in sqlalchemy is something like this:
Table.contact_info["telephones"][0]["telephone"].astext.ilike(mask)
But this only searches for the 0th element .
Currently, my stupid solution is to convert the โphonesโ to text and do it ilike, but itโs wrong, of course ...
Table._contact_info["telephones"].astext.ilike(mask)
source
share