toucan2 icon indicating copy to clipboard operation
toucan2 copied to clipboard

Models with after-update will update twice

Open qnkhuat opened this issue 6 months ago • 0 comments

(methodical/defmethod t2/table-name :model/Card [_model] :report_card)

(t2/with-call-count [call-count]
  (t2/update! :model/Card2 1 {:name "new name 1"})
  (call-count))
;; => 1
;; => UPDATE "report_card" SET "name" = ? WHERE "id" = ?

(t2/define-after-update :model/Card2
  [card]
  card)

(t2/with-call-count [call-count]
  (t2/update! :model/Card2 1 {:name "new name 1"})
  (call-count))
;; => 3
;; => UPDATE "report_card" SET "name" = ? WHERE "id" = ?
;; => SELECT * FROM "report_card" WHERE "id" IN (?)
;; => UPDATE "report_card" SET "name" = ? WHERE "id" = ?

qnkhuat avatar Aug 05 '24 10:08 qnkhuat