You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require'bundler/inline'gemfile(true)dosource"https://rubygems.org"gem'rails','7.1.3.2'gem'sqlite3','~> 1.4.0'endrequire'active_record'require'minitest/autorun'require'logger'# This connection will do for database-independent bug reports.ActiveRecord::Base.establish_connection(adapter: "sqlite3",database: ":memory:")ActiveRecord::Base.logger=Logger.new(STDOUT)ActiveRecord::Schema.definedocreate_table:keys,force: truedo |t|
t.string:key,null: falset.index:key,unique: truet.timestampsendendclassKey < ActiveRecord::BaseendclassBugTest < Minitest::TestOLD_TIME=1.day.ago.beginning_of_daydefsetupKey.destroy_alls=Key.create(key: 'abc')s.update_attribute:updated_at,OLD_TIMEend#FAILSdeftest_upsertKey.upsert({key: 'abc'},unique_by: :key)assertOLD_TIME != Key.first.updated_at,'expected updated_at to change'end#WORKS due to update of column that is not in unique_bydeftest_upsert_with_changeKey.upsert({key: 'abc',created_at: Time.now},unique_by: :key)assertOLD_TIME != Key.first.updated_at,'expected updated_at to change'endend
Expected behavior
I'm using #upsert to touch records by key and set updated_at.
upsert should update updated_at column.
Actual behavior
ON CONFLICT ("key") DO NOTHING is used and upsert does not update updated_at.
Logs:
Key Insert (0.1ms) INSERT INTO "keys" ("key","created_at","updated_at")
VALUES ('abc', STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW'), STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW'))
ON CONFLICT ("key") DO NOTHING RETURNING "id"
This issue has been automatically closed because there has been no follow-up response from the original author. We currently don't have enough information in order to take action. Please reach out if you have any additional information that will help us move this issue forward.
Steps to reproduce
Expected behavior
I'm using #upsert to touch records by key and set updated_at.
upsert should update updated_at column.
Actual behavior
ON CONFLICT ("key") DO NOTHING
is used and upsert does not update updated_at.Logs:
System configuration
Rails version: 7.3.2.1
Ruby version: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
The text was updated successfully, but these errors were encountered: