activerecord-sqlserver-adapter icon indicating copy to clipboard operation
activerecord-sqlserver-adapter copied to clipboard

ActiveRecord::ConnectionAdapters::SQLServerAdapter does not support upsert

Open fel486 opened this issue 3 years ago • 2 comments

Issue

Trying to use an upsert operation on my model, but it's showing an error telling this adapter has no implementation for that.

Expected behavior

Upsert operation working with no exceptions.

Actual behavior

Throwing an exception:

ActiveRecord::ConnectionAdapters::SQLServerAdapter does not support upsert

raise ArgumentError, "#{connection.class} does not support upsert"

How to reproduce

Simply calling

image

Details

  • Rails version: 7.0.4.3
  • SQL Server adapter version: 7.0.1.0
  • TinyTDS version: 2.1.5
  • FreeTDS details:

SQL SERVER 16.0.4003.1 - Developer Edition

fel486 avatar Mar 19 '23 04:03 fel486

The adapter doesn't support upsert as Microsoft SQL Server doesn't natively support it either. There were investigations in https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/859 to see if upsert could be supported using MERGE but they have been unsuccessful.

aidanharan avatar Mar 20 '23 09:03 aidanharan

Is there no way to implement this in SQL Server?

upsert is a valuable feature and is required for supporting Solid Cache (See #1122)

Michoels avatar Dec 07 '23 08:12 Michoels