Skip to content

Commit ecdc7eb

Browse files
authored
Fetch last value from sequence given currval may not be defined for the session (#103)
1 parent e8835a1 commit ecdc7eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/database_cleaner/active_record/truncation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def database_cleaner_table_cache
224224
def has_been_used?(table)
225225
return has_rows?(table) unless has_sequence?(table)
226226

227-
cur_val = select_value("SELECT currval('#{table}_id_seq');").to_i rescue 0
227+
cur_val = select_value("SELECT last_value from #{table}_id_seq;").to_i
228228
cur_val > 0
229229
end
230230

0 commit comments

Comments
 (0)