There is a lot of them. But I think it have to be simple. Like a normal
query.
>From the docs I understand how to cache query with FromCache, how to cache
relationship with RelationshipCache,
but I don't find how to cache polymorphic relationships.
On Tuesday, April 15, 2014 5:56:36 PM UTC+4, Gu
I might be wrong, but maybe you could also use eval if you don't know which
class at runtime.
i.e.
session.query(Person).with_polymorphic(eval(classString))
where classString is a string equal to the name of the class.
On Tuesday, April 15, 2014 6:56:36 AM UTC-7, Gunnlaugur Briem wrote:
>
> O
On Tue, Apr 15, 2014 at 1:11 PM, Pavel Aborilov wrote:
> but I dont know on the time of query what the type of object it will be.
>
Then you can use session.query(Person).with_polymorphic('*') to mean
joining to the tables of all mapped subclasses. (Be aware that this can
become problematic if t
but I dont know on the time of query what the type of object it will be.
On Tuesday, April 15, 2014 5:06:48 PM UTC+4, Gunnlaugur Briem wrote:
>
> Hi Pavel,
>
> You want: s.query(Person).with_polymorphic(Man).get(51)
>
> Cheers,
>
> Gulli
>
>
> On Tue, Apr 15, 2014 at 12:59 PM, Pavel Aborilov
>
>
Hi Pavel,
You want: s.query(Person).with_polymorphic(Man).get(51)
Cheers,
Gulli
On Tue, Apr 15, 2014 at 12:59 PM, Pavel Aborilov wrote:
> Hello!
> How can I cache query like this:
> session.query(Person).get(51)
>
> where 51 is id of Man
>
> I can't access attribute age of Man without SELECT
Hello!
How can I cache query like this:
session.query(Person).get(51)
where 51 is id of Man
I can't access attribute age of Man without SELECT.
Models:
class Person(Base):
__tablename__ = 'person'
id = Column(Integer, primary_key=True)
name = Column(String(100), nullable=False)