diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-11 10:54:08 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-11 10:54:08 -0700 |
commit | 9ba94c8fc4e7d5577e87aca07f92c9f51f08bdba (patch) | |
tree | 960f6513049195ed79b46dfc0f6a6462b8fbe97d /activerecord | |
parent | cbb65de1a60f1263cab05627ab99c9f5e246cd5c (diff) | |
download | rails-9ba94c8fc4e7d5577e87aca07f92c9f51f08bdba.tar.gz rails-9ba94c8fc4e7d5577e87aca07f92c9f51f08bdba.tar.bz2 rails-9ba94c8fc4e7d5577e87aca07f92c9f51f08bdba.zip |
we know the table and pk, so we can calculate a default sequence name
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 7 |
1 files changed, 4 insertions, 3 deletions
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 |