Bugfix to ActiveRecord PostgreSQLAdapter pre_count

This commit is contained in:
Jordan Hollinger 2012-11-13 23:22:38 -05:00
parent d1e2dc973e
commit fdc64dbbb2

View file

@ -139,8 +139,8 @@ module DatabaseCleaner
# but then the table is cleaned. In other words, this function tells us if the given table
# was ever inserted into.
def has_been_used?(table)
cur_val = select_value("SELECT currval('#{table}_id_seq');").to_i rescue ActiveRecord::StatementInvalid
cur_val && cur_val > 0
cur_val = select_value("SELECT currval('#{table}_id_seq');").to_i rescue 0
cur_val > 0
end
def has_rows?(table)