Using a trigger with an object-relational manager
| От | Rick Schumeyer |
|---|---|
| Тема | Using a trigger with an object-relational manager |
| Дата | |
| Msg-id | 46539734.3040606@ieee.org обсуждение исходный текст |
| Ответы |
Re: Using a trigger with an object-relational manager
Re: Using a trigger with an object-relational manager |
| Список | 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 по дате отправления: