diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-10 23:53:02 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-11 09:08:45 -0700 |
commit | 35b2715456999662cc34390e258962738aaa8dc7 (patch) | |
tree | 6a1e3051e661bc6e08beae8928bed3e194c12182 /activerecord/lib | |
parent | 7379114c2f2c2ec1f767a16cf2f8662ea6bd8db2 (diff) | |
download | rails-35b2715456999662cc34390e258962738aaa8dc7.tar.gz rails-35b2715456999662cc34390e258962738aaa8dc7.tar.bz2 rails-35b2715456999662cc34390e258962738aaa8dc7.zip |
only support pg >= 8.2, so no need to check
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 7546afcc18..15ced08499 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -435,13 +435,10 @@ module ActiveRecord # Extract the table from the insert sql. Yuck. table = sql.split(" ", 4)[2].gsub('"', '') - # Try an insert with 'returning id' if available (PG >= 8.2) - if supports_insert_with_returning? - pk, sequence_name = *pk_and_sequence_for(table) unless pk - if pk - id = select_value("#{sql} RETURNING #{quote_column_name(pk)}") - return id - end + pk, sequence_name = *pk_and_sequence_for(table) unless pk + if pk + id = select_value("#{sql} RETURNING #{quote_column_name(pk)}") + return id end # Otherwise, insert then grab last_insert_id. |