Robert
2012-Oct-07 00:16 UTC
Option for inserts/updates/deletes on the Postgres adapter to return all columns, not just the id
By default with Rails, Postgres will return the id of a newly inserted record using returning "id". Sometimes when working with Postgres, tables will have triggers on them that modify the row''s data while being saved. As such, it would be great to also provide an option for Postgres to also let insert/updates and deletes to use returning * (which will return the row as it looks after Postgres modified it). What are everyone''s thoughts on this? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/-MsSXG8vqSwJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Jack Christensen
2012-Oct-08 10:11 UTC
Re: Option for inserts/updates/deletes on the Postgres adapter to return all columns, not just the id
On 10/6/2012 7:16 PM, Robert wrote:> > By default with Rails, Postgres will return the id of a newly inserted > record using |returning "id"|. Sometimes when working with Postgres, > tables will have triggers on them that modify the row''s data while > being saved. As such, it would be great to also provide an option for > Postgres to also let insert/updates and deletes to use |returning > *| (which will return the row as it looks after Postgres modified it). > > What are everyone''s thoughts on this? >+1. I have run into this. Definitely a pain to have to manually call reload to get the actual values that were stored in the database.> -- > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Core" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-core/-/-MsSXG8vqSwJ. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Abdelkader Boudih
2012-Oct-08 18:52 UTC
Re: Option for inserts/updates/deletes on the Postgres adapter to return all columns, not just the id
On Sunday, 7 October 2012 01:16:17 UTC+1, Robert wrote:> > By default with Rails, Postgres will return the id of a newly inserted > record using returning "id". Sometimes when working with Postgres, tables > will have triggers on them that modify the row''s data while being saved. As > such, it would be great to also provide an option for Postgres to also let > insert/updates and deletes to use returning * (which will return the row > as it looks after Postgres modified it). > > What are everyone''s thoughts on this? >This will generate extra traffic. i think it must be an option in the model for example. * * *self.returning = "*"* ** * * -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/nc8m9lFs7HAJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Robert
2012-Oct-18 19:26 UTC
Re: Option for inserts/updates/deletes on the Postgres adapter to return all columns, not just the id
I like the idea of specifying it at the model level. this way you can pick and choose. On Monday, October 8, 2012 2:52:59 PM UTC-4, Abdelkader Boudih wrote:> > > > On Sunday, 7 October 2012 01:16:17 UTC+1, Robert wrote: >> >> By default with Rails, Postgres will return the id of a newly inserted >> record using returning "id". Sometimes when working with Postgres, >> tables will have triggers on them that modify the row''s data while being >> saved. As such, it would be great to also provide an option for Postgres to >> also let insert/updates and deletes to use returning * (which will >> return the row as it looks after Postgres modified it). >> >> What are everyone''s thoughts on this? >> > > This will generate extra traffic. i think it must be an option in the > model for example. > * > * > *self.returning = "*"* > ** > * > * >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/t5Xtn1dbTwYJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Maybe Matching Threads
- Postgres adapter issues with Rails 2.1: ruby-pg is the answer!
- SOLVED:Re: How to select postgres for usage instead postgres-pr?
- PostgreSQL, postgres gem, rails2.pdf, http://ruby.scripting.ca/postgres/ confusion...
- Postgres adapter misconfigured on Linux?
- weird postgres adapter error