2

Use correct precision when touching `updated_at` column in upsert by sambostock...

 2 years ago
source link: https://github.com/rails/rails/pull/42993
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

sambostock commented on Aug 10

edited

Summary

Closes #42992

InsertAll (the machinery which powers, among others methods, upsert) uses CURRENT_TIMESTAMP with an implicit precision of 0 as the default when touching updated_at/updated_on.

This PR updates it to pass in the current time, serialized according to the column's type.

Not all databases support increased precision for CURRENT_TIMESTAMP (e.g. MySQL supports CURRENT_TIMESTAMP(6), but SQLite does not), so it is simpler to just serialize the current time.

Other Information

warning Before Merging

  • Address TODO comments
  • Add changelog entry
  • Confirm there is no reason CURRENT_TIMESTAMP had been chosen instead of serializing the current time, and that this won't break anything.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK