bmabey/database_cleaner — pull request #218 by elffersj (2013-06-09 13:50:04+00:00)
Title: SQLite adapter: delete only if table has been used

The SQLite adapter lacks the functionality to only truncate those tables which were used. I modified this adapter to check whether tables were used before the truncation is executed.
I don't know whether this functionality was not yet implemented on purpose, but for me this gave speed-up in some cases. It only works if the table ``sqlite_sequence`` is used by SQLite.

From the [SQLite documentation](http://www.sqlite.org/fileformat2.html#seqtab):
* Table has a primary key. Then when the table is modified, the entry in ``sqlite_sequence`` is created/modified, so there is an entry in the ``sqlite_sequence`` table. If this entry exists, it must be removed and the table must be cleared if rowcount > 0.
* Table has no primary key, then there is no auto increment value to be reset, so the table must be cleared exactly if rowcount > 0.

Note: the SQLite adapter (still) ignores the configuration options ``reset_ids`` and ``pre_count``.