On Mon, Jun 3, 2019, at 3:19 PM, Jonathan Vanasco wrote:
> We have a fairly complex SqlAlchemy model that spans several integrated 
> applications (300+ tables).
> 
> Our text columns are all of the `sqlalchemy.UnicodeText` class, however they 
> all have widely different 'cleaning' or 'sanitization' schemes. This 
> typically needs to be preprocessed, as we need to derive information from 
> these fields before saving - using custom serializers isn't a concern or 
> desire. Right now we have lots of tests - which often duplicate one another 
> and are manually maintained - to ensure everything is processed correctly. A 
> layer of functional tests mocks the data processing for each object - and 
> that's not going to chance. What I'd like to change is the suite of lower 
> unit tests, which mock the various serialization schemes. 
> 
> I had an idea, and I'm wondering if this is compatible with sane SqlAlchemy 
> usage or not... 
> 
> I'd like to create a unique subclass of `sqlalchemy.UnicodeText` for each 
> type of data serialization our models use (currently there are 10). 
> 
> The subclasses will simply 'pass', and will just be used by the test suite to 
> auto-detect the desired serialization format and ensure tests pass... and 
> also essentially document what the intended serialization format is.
> 
> Does this generally sound okay, or is this likely to screw up the internals? 
> Tests so far show this as not affecting anything negatively. 

It's probably better to use TypeDecorator since that keeps the two roles 
separate.  you could also put bind/result handlers on them to assert things if 
you wanted...


> 
> If anyone else has an idea on a better way to handle this, I'd be excited to 
> learn about it. This just seemed like a low-cost way to simplify our needs 
> for testing and developer documentation.
> 
> 

> --
>  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 post to this group, send email to sqlalchemy@googlegroups.com.
>  Visit this group at https://groups.google.com/group/sqlalchemy.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/fd95dcf8-7823-4a4f-96b4-134d51eb29d4%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/fd95dcf8-7823-4a4f-96b4-134d51eb29d4%40googlegroups.com?utm_medium=email&utm_source=footer>.
>  For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/39344047-0fe0-4759-a8ee-dba9093bb295%40www.fastmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to