I have a table as follows:
CREATE TABLE partes(
id INTEGER PRIMARY KEY,
id_padre INTEGER,
tipos JSON
);
I insert the sample data:
INSERT INTO partes (id, id_padre, tipos) VALUES (1, 0, '["1","2"]'), (2, 1, '["2"]'), (3, 1, '["2","1"]'), (4, 3, '["1"]');
I make the query:
select * from partes where tipos = '["1"]' order by id_padre;
The value I get is the following:
Query Error: error: operator does not exist: json = unknown
Here in fiddler to see how it works: dbfiddler
You have two options:
Change to
JSONB
:The other option is passing
jsonb
to your query: