aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-04-11 10:31:13 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-04-11 10:31:13 -0700
commit302b6f3f73731c8daa108f9c40d7cf41463898d8 (patch)
tree81ff354c9386532a854cdc58bf72f27fe10150e0 /activerecord
parent4c30304e159b2a8fafb5b3c5c8b6d996e490e657 (diff)
downloadrails-302b6f3f73731c8daa108f9c40d7cf41463898d8.tar.gz
rails-302b6f3f73731c8daa108f9c40d7cf41463898d8.tar.bz2
rails-302b6f3f73731c8daa108f9c40d7cf41463898d8.zip
pg does not know the insert_id in advance, so super will never return true
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb23
1 files changed, 10 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index a0be143c8e..a90e9a4b71 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -441,20 +441,17 @@ module ActiveRecord
return id
end
- # Otherwise, insert then grab last_insert_id.
- if insert_id = super
- insert_id
- else
- # If neither pk nor sequence name is given, look them up.
- unless pk || sequence_name
- pk, sequence_name = *pk_and_sequence_for(table)
- end
+ super
- # 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
+ # If neither pk nor sequence name is given, look them up.
+ unless pk || sequence_name
+ pk, sequence_name = *pk_and_sequence_for(table)
+ end
+
+ # 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
end
alias :create :insert