M
M
Mikhail Anc2020-05-18 16:15:54
PostgreSQL
Mikhail Anc, 2020-05-18 16:15:54

Sampling with postgre by jsonb intersection?

I have a view with jsonb, I need to find the intersection of the data

request, it works, I'm trying to do the same in the code

select * from "ListView" 
where("Relationship" @> '[{"Type": "Action", "RelationshipId": "3"}]');


filterParams.Append("Relationship", $"\"Relationship\" @> @Relationship", $"'[{{\"Type\": \"{Relationship.Type}\", \"RelationshipId\": \"{Relationship.Id}\"}}]'");


I constantly get this error, I tried to substitute ::jsonb from different sides, to no avail...
[ERROR] 42883: operator does not exist: jsonb @> text    at Npgsql.NpgsqlConnector.<>c__DisplayClass161_0

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Anc, 2020-05-18
@AncientD

it was necessary to remove the single '
because at startup the builder wraps itself
and add jsonb to the
values

filterParams.Append("Relationship", $"\"Relationship\" @> @Relationship::jsonb", $"[{{\"Type\": \"{Relationship.Type}\", \"RelationshipId\": \"{Relationship.Id}\"}}]");

G
galaxy, 2020-05-18
@galaxy

The question is more about C # (in which I don’t understand), but what if it’s like this:

filterParams.Append("Relationship", $"\"Relationship\" @> @Relationship::jsonb", ....);

?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question