Permalink
Browse files

we know the table and pk, so we can calculate a default sequence name

  • Loading branch information...
1 parent cbb65de commit 9ba94c8fc4e7d5577e87aca07f92c9f51f08bdba @tenderlove tenderlove committed Apr 11, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -447,11 +447,12 @@ def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
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

0 comments on commit 9ba94c8

Please sign in to comment.