pg does not know the insert_id in advance, so super will never return true

This commit is contained in:
Aaron Patterson 2011-04-11 10:31:13 -07:00
parent 4c30304e15
commit 302b6f3f73

@ -441,20 +441,17 @@ def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
return id return id
end end
# Otherwise, insert then grab last_insert_id. super
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
# If a pk is given, fallback to default sequence name. # If neither pk nor sequence name is given, look them up.
# Don't fetch last insert id for a table without a pk. unless pk || sequence_name
if pk && sequence_name ||= default_sequence_name(table, pk) pk, sequence_name = *pk_and_sequence_for(table)
last_insert_id(sequence_name) end
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
end end
alias :create :insert alias :create :insert