Using a trigger with an object-relational manager - Mailing list pgsql-general

From Rick Schumeyer
Subject Using a trigger with an object-relational manager
Date
Msg-id 46539734.3040606@ieee.org
Whole thread Raw
Responses Re: Using a trigger with an object-relational manager
Re: Using a trigger with an object-relational manager
List pgsql-general
I'm using Ruby on Rails and have two tables, A and B.  Every row in A
needs a corresponding row in B.  A also contains a FK pointing to B.

I created a before insert trigger on A that inserts a new row in B, and
sets the FK in A.  This seems to be running fine.

The problem is that the new A object that rails gets does not see the
effect of the trigger.  If I call the "reload" method, then everything
is ok.

I'm not sure if this is a rails specific problem, or if there is an
adjustment I can make to my SQL to avoid the need for the reload.

Can I somehow put the creation of A, B and setting the FK in a
transaction so that rails receives the row from A after the trigger
completes?  If so, I'm not sure the best way to do that.

Thanks for any suggestions!

pgsql-general by date:

Previous
From: "Joris Dobbelsteen"
Date:
Subject: Re: Lock table, Select for update and Serialization error
Next
From: Naz Gassiep
Date:
Subject: Integrity on large sites