Re: remaining sql/json patches
От | Anton A. Melnikov |
---|---|
Тема | Re: remaining sql/json patches |
Дата | |
Msg-id | c04ff761-930b-4345-ae23-f78b8ee7ce32@postgrespro.ru обсуждение исходный текст |
Ответ на | Re: remaining sql/json patches (jian he <jian.universality@gmail.com>) |
Ответы |
Re: remaining sql/json patches
|
Список | pgsql-hackers |
Hello! On 16.10.2023 15:49, jian he wrote: > add the following code after ExecEvalJsonExprCoercion if > (!InputFunctionCallSafe(...) works, but seems like a hack. > > if (!val_string) > { > *op->resnull = true; > *op->resvalue = (Datum) 0; > } It seems the constraint should work here: After CREATE TABLE test ( js text, i int, x jsonb DEFAULT JSON_QUERY(jsonb '[1,2]', '$[*]' WITH WRAPPER) CONSTRAINT test_constraint CHECK (JSON_QUERY(js::jsonb, '$.a' RETURNING char(5) OMIT QUOTES EMPTY ARRAY ON EMPTY) > 'a') ); INSERT INTO test_jsonb_constraints VALUES ('[]'); one expected to see an error like that: ERROR: new row for relation "test" violates check constraint "test_constraint" DETAIL: Failing row contains ([], null, [1, 2]). not "INSERT 0 1" With best regards, -- Anton A. Melnikov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company
В списке pgsql-hackers по дате отправления: