Hi Rails (specifically ActiveRecord) developers: please consider the following patch to : lib/active_record/connection_adapters/postgresql_adapter.rb: This patch is against version 1.15.3: $ diff -u lib/active_record/connection_adapters/ postgresql_adapter.rb /tmp --- lib/active_record/connection_adapters/postgresql_adapter.rb 2007-01-14 18:26:06.000000000 -0800 +++ /tmp/postgresql_adapter.rb 2007-09-30 10:46:33.000000000 -0700 @@ -133,6 +133,17 @@ # DATABASE STATEMENTS ===================================== def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc: + + # http://www.postgresql.org/docs/8.1/interactive/sql-insert.html + # using regexp to convert : INSERT INTO xxx () VALUES() + # into : : INSERT INTO xxx DEFAULT VALUES + # m[1] is the table name. + + m = /INSERT\s*INTO\s*(\S+)\s*\(\)\s*VALUES\s*\(\)/.match(sql) + if m + sql = "INSERT INTO #{m[1]} DEFAULT VALUES" + end + execute(sql, name) table = sql.split(" ", 4)[2] id_value || last_insert_id(table, sequence_name || default_sequence_name(table, pk)) eugene-j-koontzs-computer:/tmp/activerecord-1.15.3 ekoontz$ diff -u lib/active_record/connection_adapters/postgresql_adapter.rb /tmp --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
\> Hi Rails (specifically ActiveRecord) developers: please consider the > following patch to : > > lib/active_record/connection_adapters/postgresql_adapter.rb:Hi there, Inserting empty records has been handled, in a different way, in edge rails, this will work in 2.0. Thanks,> > This patch is against version 1.15.3: > > $ diff -u lib/active_record/connection_adapters/ > postgresql_adapter.rb /tmp > --- lib/active_record/connection_adapters/postgresql_adapter.rb > 2007-01-14 18:26:06.000000000 -0800 > +++ /tmp/postgresql_adapter.rb 2007-09-30 10:46:33.000000000 -0700 > @@ -133,6 +133,17 @@ > # DATABASE STATEMENTS =====================================> > def insert(sql, name = nil, pk = nil, id_value = nil, > sequence_name = nil) #:nodoc: > + > + # http://www.postgresql.org/docs/8.1/interactive/sql-insert.html > + # using regexp to convert : INSERT INTO xxx () VALUES() > + # into : : INSERT INTO xxx DEFAULT VALUES > + # m[1] is the table name. > + > + m = /INSERT\s*INTO\s*(\S+)\s*\(\)\s*VALUES\s*\(\)/.match(sql) > + if m > + sql = "INSERT INTO #{m[1]} DEFAULT VALUES" > + end > + > execute(sql, name) > table = sql.split(" ", 4)[2] > id_value || last_insert_id(table, sequence_name || > default_sequence_name(table, pk)) > eugene-j-koontzs-computer:/tmp/activerecord-1.15.3 ekoontz$ diff -u > lib/active_record/connection_adapters/postgresql_adapter.rb /tmp > > > > >-- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On E, 2007-10-01 at 10:02 +1300, Michael Koziarski wrote:> Hi there, > > Inserting empty records has been handled, in a different way, in edge > rails, this will work in 2.0.Actually it hasn''t been fixed, there was an attempt with: http://dev.rubyonrails.org/ticket/9253 But it ran into a problem with databases that needed primary key prefetch and the ticket is currently waiting for some ideas on how to approach the issue. I think I could get the patch to work by just keeping the PK prefetch and going with the insert_record(table_name, attributes) but I''m not even sure anymore if that would be a good approach. Perhaps the easiest fix would be to just let the adapters implement insert_blank_statement() (so they could each provide their way of inserting a blank row) and generate the SQL in AR::Base.create() in case there are no columns to insert. Any ideas? -- Tarmo Tänav <tarmo@itech.ee> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/1/07, Tarmo Tänav <tarmo@itech.ee> wrote:> > On E, 2007-10-01 at 10:02 +1300, Michael Koziarski wrote: > > Hi there, > > > > Inserting empty records has been handled, in a different way, in edge > > rails, this will work in 2.0. > > Actually it hasn''t been fixed, there was an attempt with: > http://dev.rubyonrails.org/ticket/9253 > But it ran into a problem with databases that needed primary key > prefetch and the ticket is currently waiting for some ideas on > how to approach the issue.Oh right, never mail the list when jetlagged :).> Perhaps the easiest fix would be to just let the adapters implement > insert_blank_statement() (so they could each provide their way of inserting > a blank row) and generate the SQL in AR::Base.create() in case there > are no columns to insert.That does sound like a reasonable start. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ekoontz@hiro-tan.org
2007-Oct-01 01:38 UTC
Re: fix for postgresql_adapter.rb : INSERT syntax
On Sep 30, 3:15 pm, Tarmo Tänav <ta...@itech.ee> wrote:> On E, 2007-10-01 at 10:02 +1300, Michael Koziarski wrote: > > > Hi there, > > > Inserting empty records has been handled, in a different way, in edge > > rails, this will work in 2.0. > > Actually it hasn''t been fixed, there was an attempt with:http://dev.rubyonrails.org/ticket/9253 > But it ran into a problem with databases that needed primary key > prefetch and the ticket is currently waiting for some ideas on > how to approach the issue. > > I think I could get the patch to work by just keeping the PK prefetch > and going with the insert_record(table_name, attributes) but I''m not > even sure anymore if that would be a good approach. > > Perhaps the easiest fix would be to just let the adapters implement > insert_blank_statement() (so they could each provide their way of inserting > a blank row) and generate the SQL in AR::Base.create() in case there > are no columns to insert. > > Any ideas? > > -- > Tarmo Tänav <ta...@itech.ee>Dear Tarmo, I am new to the list; but I am starting to wonder how many core rails developers are using Postgres versus other databases? What is the status of support/quality of the various database drivers compared to MySQL, which seems to be the dominant server? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I am new to the list; but I am starting to wonder how many core > rails developers are using Postgres versus other databases? What is > the status of support/quality of the various database drivers compared > to MySQL, which seems to be the dominant server?I''m not sure that anyone on the core team is currently using PostgreSQL in their projects. However the tests still get run by the CI system, and there are several active users who tend to submit patches when something''s broken. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ekoontz@hiro-tan.org
2007-Oct-01 03:34 UTC
Re: fix for postgresql_adapter.rb : INSERT syntax
Dear Koz, Thanks for your reply; perhaps I will looking into submiting a test that shows the bug that Tarmo is describing on his very informative writeup at http://dev.rubyonrails.org/ticket/9253. On Sep 30, 8:28 pm, "Michael Koziarski" <mich...@koziarski.com> wrote:> > I am new to the list; but I am starting to wonder how many core > > rails developers are using Postgres versus other databases? What is > > the status of support/quality of the various database drivers compared > > to MySQL, which seems to be the dominant server? > > I''m not sure that anyone on the core team is currently using > PostgreSQL in their projects. However the tests still get run by the > CI system, and there are several active users who tend to submit > patches when something''s broken. > > -- > Cheers > > Koz--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On P, 2007-09-30 at 20:34 -0700, ekoontz@hiro-tan.org wrote:> Dear Koz, > Thanks for your reply; perhaps I will looking into submiting a test > that shows the bug that Tarmo is describing on his very informative > writeup at http://dev.rubyonrails.org/ticket/9253.There are already tests attached to the ticket. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---