1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

only support pg >= 8.2, so no need to check

This commit is contained in:
Aaron Patterson 2011-04-10 23:53:02 -07:00
parent 7379114c2f
commit 35b2715456

View file

@ -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.