rails-sqlserver / activerecord-sqlserver-adapter

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

ActiveRecord::ConnectionAdapters::SQLServerAdapter does not support upsert #1044

Closed felzend closed 1 year ago

felzend commented 1 year ago

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

SQL SERVER 16.0.4003.1 - Developer Edition

aidanharan commented 1 year ago

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.

Michoels commented 10 months ago

Is there no way to implement this in SQL Server?

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