Hi, I have been doing some tests to solve a requirement given in where an object must check some of the values on its attributes before an insert or an update gets triggered into the db.
Did some tests with validates decorator and because some of the fields require other fields to be set before, cannot use it. Solved that using events and before_insert/before_update events. Listening for events has the disadvantage that all created instances will be checked, no matter if they were added or not to the session. Beyond that, I also have to make a field validate to its previous value, and cannot find a way to do this without making other queries. In my case is a field called state_id that is a foreign key to another table and who has a strict flow that must follow, so when updated it must check for the previous value to see if the new value is allowed. Here <https://gist.github.com/kyheo/af2a333b850e6eb2fa93> are some of the tests I've done. But still not sure if I'm taking the right approach for the fields validation, and still haven't found a way to test state_id field. Any hep, hint or direction to the proper doc page will be appreciated. Thanks, MartÃn -- Martin A. Marrese marr...@gmail.com +54 911 5112 9448 -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.