Table: RailsNotes
User: dreamable
Created at: 2020-11-12 07:10:04 UTC
Updated at: 2020-11-12 23:20:33 UTC
Reference:(Table ID 3, Record ID 3)

标题 :
destroy_all vs delete_all
笔记 :
  • https://stackoverflow.com/questions/6698207/delete-all-vs-destroy-all

    • destroy_all: call destroy method of all matched objects. i.e. one SQL for one object
    • delete_all: one SQL delete for all matched results.

      • NOTE:It seems to be update if use reference e.g.

           table.datetime_cells.delete_all 
            DatetimeCell Update All (0.3ms)  UPDATE "datetime_cells" SET "table_id" = $1 WHERE "datetime_cells"."table_id" = $2  [["table_id", nil], ["table_id", 7]]
           datetime_cells.where(table:talbe).delete_all # OK
        
Tag: