Skip to content

Commit

Permalink
Fetch last value from sequence given currval may not be defined for t…
Browse files Browse the repository at this point in the history
…he session (#103)
  • Loading branch information
cwjenkins committed Jul 12, 2024
1 parent e8835a1 commit ecdc7eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/database_cleaner/active_record/truncation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def database_cleaner_table_cache
def has_been_used?(table)
return has_rows?(table) unless has_sequence?(table)

cur_val = select_value("SELECT currval('#{table}_id_seq');").to_i rescue 0
cur_val = select_value("SELECT last_value from #{table}_id_seq;").to_i
cur_val > 0
end

Expand Down

0 comments on commit ecdc7eb

Please sign in to comment.