From 9ba94c8fc4e7d5577e87aca07f92c9f51f08bdba Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 11 Apr 2011 10:54:08 -0700 Subject: we know the table and pk, so we can calculate a default sequence name --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 617d131c40..392eadb9d5 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -447,11 +447,12 @@ module ActiveRecord super + return unless pk + # If a pk is given, fallback to default sequence name. # Don't fetch last insert id for a table without a pk. - if pk && sequence_name ||= default_sequence_name(table, pk) - last_insert_id(sequence_name) - end + sequence_name ||= "#{table}_#{pk}_seq" + last_insert_id(sequence_name) end alias :create :insert -- cgit v1.2.3