Re: [sqlalchemy] When to set "cache_ok" to True?

2021-05-26 Thread Mike Bayer
most (although some are missing) of the examples illustrate it such as https://docs.sqlalchemy.org/en/14/core/custom_types.html#store-timezone-aware-timestamps-as-timezone-naive-utc class TZDateTime(TypeDecorator): impl = DateTime cache_ok = True def process_bind_param(self, value,

Re: [sqlalchemy] When to set "cache_ok" to True?

2021-05-26 Thread Jinghui Niu
Thank you. Could you please also give some hint on a case where we must set this attribute to `False`? On Wed, May 26, 2021 at 5:54 AM Mike Bayer wrote: > > > On Wed, May 26, 2021, at 3:07 AM, niuji...@gmail.com wrote: > > I have consistently receiving the warning: > will not produce a cache

Re: [sqlalchemy] Multiple mappers found by get_mapper - model inheritance

2021-05-26 Thread Mike Bayer
OK then please report this as a bug in sqlalchemy-utils right now they are not looking at local table looking at the code here: https://sqlalchemy-utils.readthedocs.io/en/latest/_modules/sqlalchemy_utils/functions/orm.html#get_mapper code can be like: mappers = [ mapper

Re: [sqlalchemy] Multiple mappers found by get_mapper - model inheritance

2021-05-26 Thread piotr maliński
It's from sqlalchemy_utils - https://sqlalchemy-utils.readthedocs.io/en/latest/orm_helpers.html#get-mapper śr., 26 maj 2021 o 17:47 Mike Bayer napisał(a): > get_mapper() is not part of SQLAlchemy where is it? > > On Wed, May 26, 2021, at 9:35 AM, piotr maliński wrote: > > AnnotatedTable

Re: [sqlalchemy] Multiple mappers found by get_mapper - model inheritance

2021-05-26 Thread Mike Bayer
get_mapper() is not part of SQLAlchemy where is it? On Wed, May 26, 2021, at 9:35 AM, piotr maliński wrote: > AnnotatedTable doesn't have a mapper so I call: > > get_mapper(annotated_table_object_here) > > To then map a column name to a column on a model with _entity_descriptor. In >

Re: [sqlalchemy] Multiple mappers found by get_mapper - model inheritance

2021-05-26 Thread piotr maliński
AnnotatedTable doesn't have a mapper so I call: get_mapper(annotated_table_object_here) To then map a column name to a column on a model with _entity_descriptor. In get_mapper this seems to hit the "if isinstance(mixed, sa.Table):" branch and: if mixed in mapper.tables ends true to all 3 of

Re: [sqlalchemy] Multiple mappers found by get_mapper - model inheritance

2021-05-26 Thread Mike Bayer
I would need to see what get_mapper() is doing. the best way to associate the relevant table to a mapper is to look at inspect(Class).mapper.local_table. On Wed, May 26, 2021, at 9:18 AM, Piotr wrote: > I'm updating "sqlalchemy_django_query" for SQLAlchemy 1.4 and aside of that I > found a

[sqlalchemy] Multiple mappers found by get_mapper - model inheritance

2021-05-26 Thread Piotr
I'm updating "sqlalchemy_django_query" for SQLAlchemy 1.4 and aside of that I found a peculiar problem - when I call get_mapper on a table (AnnotatedTable) I get a ValueError due to multiple mappers found. The model is inherited by two other models and get_mapper finds mappers for all 3

Re: [sqlalchemy] When to set "cache_ok" to True?

2021-05-26 Thread Mike Bayer
On Wed, May 26, 2021, at 3:07 AM, niuji...@gmail.com wrote: > I have consistently receiving the warning: > will not produce a cache key because the ``cache_ok`` flag is not set to > True. Set this flag to True if this type object's state is safe to use in a >

[sqlalchemy] When to set "cache_ok" to True?

2021-05-26 Thread niuji...@gmail.com
I have consistently receiving the warning: will not produce a cache key because the ``cache_ok`` flag is not set to True. Set this flag to True if this type object's state is safe to use in a cache key, or False to disable this warning. After reading the documentation, I learned that the