rails-sqlserver / activerecord-sqlserver-adapter

SQL Server Adapter For Rails
MIT License
972 stars 559 forks source link

Translate exceptions #1078

Closed aidanharan closed 1 year ago

aidanharan commented 1 year ago

Translation of exceptions has changed in Rails since https://github.com/rails/rails/commit/da52b0d954a356421ccc064df3b1285f2ba10eb5

PR translates exceptions if they happen during sp_executesql.

This fixes the following error from https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/actions/runs/5877896924/job/15938914187

2023-08-16T11:00:18.3284577Z UniquenessValidationTest#test_validate_uniqueness_with_limit_and_utf8_coerced [/activerecord-sqlserver-adapter/test/cases/coerced_tests.rb:21]:
2023-08-16T11:00:18.3285619Z [ActiveRecord::ValueTooLong] exception expected, not
2023-08-16T11:00:18.3286456Z Class: <TinyTds::Error>
2023-08-16T11:00:18.3287205Z Message: <"String or binary data would be truncated.">
2023-08-16T11:00:18.3287740Z ---Backtrace---
2023-08-16T11:00:18.3290244Z activerecord-sqlserver-adapter/lib/active_record/connection_adapters/sqlserver/database_statements.rb:459:in `each'

Ref: https://github.com/rails/rails/commit/da52b0d954a356421ccc064df3b1285f2ba10eb5