there’s a setting known as “passive_deletes=‘all’” which is intended not just to block the relationship from emitting a SELECT for rows to be deleted, but also prevents the DELETE from taking place entirely. However, the “all” part of this feature is not implemented for many-to-many relationships right now - while a many-to-many with passive_deletes=True will forego emitting a SELECT for unloaded rows, it still emits DELETE for those rows which it knows about in memory. It does at least emit the DELETE within an “executemany” so is an efficient operation.
The delete for the related object here only occurs when cascade=“delete” is set. If you didn’t have this cascade set up, the delete of the primary object would only delete the association rows, which is appropriate. if these association rows are actually mapped elsewhere in some more elaborate way then you shouldn’t be using “secondary” in this way, you’d use the association object pattern.