Re: Trigger is not working for Inserts from the application - Mailing list pgsql-general

From Kiran
Subject Re: Trigger is not working for Inserts from the application
Date
Msg-id CAJfd1U5O6XNAVxjJU+hmBEP-WNXCZJcrHjM3TjBuS+PE1b8LgQ@mail.gmail.com
Whole thread Raw
In response to Re: Trigger is not working for Inserts from the application  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Trigger is not working for Inserts from the application  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
Hi Adrian,

The JSON value is inserted into a column in the database which I can see. 
But the trigger which has to convert this JSON value in not tsvector column is not updating that column.

regards

On Sat, Sep 10, 2016 at 10:27 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Kiran <bangalore.kiran@gmail.com> writes:
> LOG:  execute <unnamed>: INSERT INTO "myschema"."cf_question"
> ("cf_question_type_id", "cf_question_category_id", "lang", "body") VALUES
> ($1, $2, $3, $4) RETURNING *
> DETAIL:  parameters: $1 = '1', $2 = '9', $3 = 'swedish', $4 = '{"name": "Do
> you like Pizza ?", "type": "cat", "store": [{"labeltext": "Yes",
> "labelvalue": 1}, {"labeltext": "No", "labelvalue": 2}, {"labeltext":
> "Other", "labelvalue": 3}, {"labeltext": "Don''t know", "labelvalue": 4}],
> "target": {"place": "Sweden"}, "askfreq": "once", "whydesc": "Because I
> like it :)"}'

Well, the obvious comment on that is "that JSON value hasn't got any qtext
field".  So the ->> operator is returning null, the coalesce() is
replacing that with an empty string, and you end up with an empty
tsvector column.

                        regards, tom lane

pgsql-general by date:

Previous
From: Jeff Janes
Date:
Subject: Re: Question about locking and pg_locks
Next
From: Adrian Klaver
Date:
Subject: Re: Trigger is not working for Inserts from the application