Merge pull request #49 from greg-barnett/database_cleaner

---

This solves the following issue:  when truncating in postgresql, the sequences are not reset.

If you have a test that depends on records getting specific ids when created, the test could fail.
This commit is contained in:
Ben Mabey 2011-03-08 19:12:10 -07:00
commit fa13e77ad7

View file

@ -70,8 +70,12 @@ module ActiveRecord
@cascade ||= db_version >= "08.02" ? "CASCADE" : ""
end
def restart_identity
@restart_identity ||= db_version >= "08.04" ? "RESTART IDENTITY" : ""
end
def truncate_table(table_name)
execute("TRUNCATE TABLE #{quote_table_name(table_name)} #{cascade};")
execute("TRUNCATE TABLE #{quote_table_name(table_name)} #{restart_identity} #{cascade};")
end
end