Merge pull request #84 from jhollinger/master

Truncation should reset a table's id column
This commit is contained in:
Ben Mabey 2011-12-07 08:27:02 -08:00
commit 0e42715d1f
2 changed files with 4 additions and 1 deletions

View file

@ -54,6 +54,7 @@ module ActiveRecord
class SQLite3Adapter < SQLITE_ADAPTER_PARENT
def delete_table(table_name)
execute("DELETE FROM #{quote_table_name(table_name)};")
execute("DELETE FROM sqlite_sequence where name = '#{table_name}';")
end
alias truncate_table delete_table
end

View file

@ -53,6 +53,7 @@ module DataMapper
def truncate_table(table_name)
execute("DELETE FROM #{quote_name(table_name)};")
execute("DELETE FROM sqlite_sequence where name = '#{table_name}';")
end
# this is a no-op copied from activerecord
@ -79,6 +80,7 @@ module DataMapper
def truncate_table(table_name)
execute("DELETE FROM #{quote_name(table_name)};")
execute("DELETE FROM sqlite_sequence where name = '#{table_name}';")
end
# this is a no-op copied from activerecord
@ -107,7 +109,7 @@ module DataMapper
end
def truncate_table(table_name)
execute("TRUNCATE TABLE #{quote_name(table_name)} CASCADE;")
execute("TRUNCATE TABLE #{quote_name(table_name)} RESTART IDENTITY CASCADE;")
end
# FIXME