Skip to content

Commit

Permalink
Update database_statements.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan committed Dec 10, 2024
1 parent 8b3c4e5 commit 17d0b78
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def perform_query(raw_connection, sql, binds, type_casted_binds, prepare:, notif

verified!

# binding.pry if $DEBUG

notification_payload[:affected_rows] = affected_rows(result)
notification_payload[:row_count] = result.count
result
Expand All @@ -41,6 +43,9 @@ def cast_result(raw_result)
end

def affected_rows(raw_result)

# raw_result.first['AffectedRows']

raw_result&.first&.fetch('AffectedRows', 0) || 0
end

Expand Down Expand Up @@ -70,10 +75,10 @@ def exec_update(sql, name = nil, binds = [])
super(sql, name, binds)
end

def exec_insert_all(sql, name)
sql = sql.dup << "; SELECT @@ROWCOUNT AS AffectedRows"
super(sql, name)
end
# def exec_insert_all(sql, name)
# sql = sql.dup << "; SELECT @@ROWCOUNT AS AffectedRows"
# super(sql, name)
# end

def begin_db_transaction
internal_execute("BEGIN TRANSACTION", "TRANSACTION", allow_retry: true, materialize_transactions: false)
Expand Down

0 comments on commit 17d0b78

Please sign in to comment.