fix for postgresql_adapter.rb : INSERT syntax

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:

\

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,

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?

> 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.

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?

   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.

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.