Closed
Description
To determine the field class to be used for a SQLAlchemy column, we sometimes check its python_type
. But some columns, e.g. Postgres TSVECTOR
columns, don't have a python_type
and raise a NotImplementedError
on trying to access. Some possible fixes:
- Add
TSVECTOR
toSQLA_TYPE_MAPPING
. This would kind of fix the immediate problem I'm running into, but what's the right marshmallow type to use? We could useStr
, but that's not exactly right. Also, this doesn't help if other columns are missingpython_type
, which might or might not be the case. - Allow developers to exclude unusual fields from model conversion, e.g. via the
Meta.exclude
option in marshmallow. This is more flexible but requires developers to understand that they can / should exclude columns that don't convert to fields. - Don't raise an exception on failing to convert a column to a field. Possibly add a
strict
option tofields_for_model
, such thatModelConversionErrors
are only raised whenstrict
is true. This is also flexible, but allows developers to silence potentially heterogeneous kinds of exceptions.
I'm submitting a patch for the second option, mostly so I can get some unrelated work done, but I think the third also makes sense, and it might not be bad to use both. What do you think @sloria?
Metadata
Metadata
Assignees
Labels
No labels