Comment on page
Bulk update
Any simple query can be transformed to
update
query. The new update query will use the where
clause as parameter for the update.User.query.where(name =~ /[A-Z]/ ).
to_update.set(name: Clear::SQL.unsafe("LOWERCASE(name)")).execute
Same apply for DELETE query.
User.query.where(name !~ /[A-Z]/ ).
to_delete.execute
Beware: Bulk update and delete do not trigger any model lifecycle hook. Proceed with care.
Last modified 4yr ago