-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
Not sure why I never noticed this before, but we have this method:
avram/src/avram/primary_key_methods.cr
Lines 75 to 77 in 8031155
| def delete | |
| self.class.write_database.exec "DELETE FROM #{@@table_name} WHERE #{primary_key_name} = #{escape_primary_key(id)}" | |
| end |
This means you can do this
user = UserQuery.find(1)
user.delete
SaveUser.update!(user)
The issue here is that this sort of breaks the repository pattern, and also circumvents the whole point of Delete operations. You can't run any other SQL directly against a model, so deleting a model directly should also be restricted.
I didn't look too far in to it, but it's possible this existed before we added DeleteOperations... In any case, we should deprecate the direct use of calling model.delete, then later remove it so you have to use a DeleteOperation instead (or bulk query).
Metadata
Metadata
Assignees
Labels
No labels