When you have a column calculated in Postgres, you need to call reload for the values to fetched from the DB.
I think it would be great if rails models could accept a list of parameters that shuold be returned after a DB operation using postgres RETURNING feature, just like it is happening with the record id.
I have opened a PR implementing this feature for create operation. The test suite is in red for now but the relevant test is passing locally.
Adding this feature has been discussed in this GH issue, but I’m posting it here per @matthewd 's suggestion.
Please let me know if you guys think this feature will be accepted and I will continue working in the PR.
I’m very interested in this feature. There is a PR. Is there any way to get review from a Rails committer? Is there anything anyone else can do to help move it along? I can spend time on it if there is any way to do so that would help.
I would like to see this feature in action for people who want to use returning feature with more attributes.
One use case I would like to describe is when you use views that can INSERT, in a view you could have a computed value using a CASE condition, because of this you need to reload the object when you create it.