Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix affected rows count when lowercase schema reflection enabled #1306

Merged
merged 4 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

#### Fixed

- [#1306](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1306) Fix affected rows count when lowercase schema reflection enabled

## v8.0.2

#### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def cast_result(raw_result)
end

def affected_rows(raw_result)
raw_result.first['AffectedRows']
column_name = lowercase_schema_reflection ? 'affectedrows' : 'AffectedRows'
raw_result.first[column_name]
end

def raw_execute(sql, name = nil, binds = [], prepare: false, async: false, allow_retry: false, materialize_transactions: true, batch: false)
Expand Down
19 changes: 19 additions & 0 deletions test/cases/adapter_test_sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require "models/subscriber"
require "models/minimalistic"
require "models/college"
require "models/discount"

class AdapterTestSQLServer < ActiveRecord::TestCase
fixtures :tasks
Expand Down Expand Up @@ -183,6 +184,24 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
assert_equal "Favorite number?", SSTestUppered.last.column1
assert SSTestUppered.columns_hash["column2"]
end

it "destroys model with no associations" do
connection.lowercase_schema_reflection = true

assert_nothing_raised do
discount = Discount.create!
discount.destroy!
end
end

it "destroys model with association" do
connection.lowercase_schema_reflection = true

assert_nothing_raised do
post = Post.create!(title: 'Setup', body: 'Record to be deleted')
post.destroy!
end
end
end

describe "identity inserts" do
Expand Down
Loading