On Mon, Oct 4, 2021, at 9:49 PM, niuji...@gmail.com wrote:
> I have the following validator:
> 
>     @sa_orm.validates('variant_names', include_removes=True)
>     def validate_unique_identifying(self, key, name_dict,
>                                     is_remove):
>         if is_remove:
>             raise ValueError("DOn't")
>         else:
>             if name_dict.is_primary_identifying_flag is None:
>                 name_dict.is_primary_identifying_flag = False
>             return name_dict
> 
> 
> When deleting, I get the raised ValueError, but the deletion occured anyway.
> Is this the expected behaviour? 

not as of SQLAlchemy 1.3, nope.   valueerror will prevent removal from a 
collection assuming you are using list.remove() or set.remove().  may not work 
for pop().



> 
> Or there is some other settings that can prevent the deletion?
> 
> 
> -- 
> SQLAlchemy - 
> The Python SQL Toolkit and Object Relational Mapper
>  
> http://www.sqlalchemy.org/
>  
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/a51745a0-3a49-4613-bd17-35920bfd5fe9n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/a51745a0-3a49-4613-bd17-35920bfd5fe9n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/f0b07312-f86b-4c87-aa6b-54f79001242e%40www.fastmail.com.

Reply via email to