This is not working:
Setup:
--------------------------------------------------------------------
base = Table("base", metadata,
Column("id", Integer, primary_key=True),
Column("kind", Integer),
)
derived = Table("derived", metadata,
Column("id", Integer, ForeignKey("base.id"), primary_key=True)
)
class Base(object): pass
class Derived(Base): pass
mapper(Base, base,
polymorphic_on=base.c.kind,
polymorphic_identity=0,
)
mapper(Derived, derived,
inherits=Base,
polymorphic_identity=1,
)
--------------------------------------------------------------------
and this call:
session.query(Base).with_polymorphic(Base).first()
will still result in 2 SELECTs and the returned object is Derived
(tables are filled only with Derived objects)
SELECT base.id AS base_id, base.kind AS base_kind
FROM base ORDER BY base.id
LIMIT 1 OFFSET 0
SELECT derived.id AS derived_id
FROM derived
WHERE %(param_1)s = derived.id
<__main__.Derived object at 0xce1b10>
SQLAlchemy version 0.4.7p1
I need only 1 SELECT and Base object returned.
Michael Bayer napsal(a):
> call with_polymorphic passing in only the base class:
>
> query.with_polymorphic(BaseClass).filter()....
>
>
> On Aug 25, 2008, at 10:35 AM, ml wrote:
>
>> Hi!
>>
>> How can I disable a polymorphic load for a single query? I found a
>> hint
>> in http://markmail.org/message/2kwbm377j3pdvvqb but I can't find more.
>>
>> Thanks for any advice.
>>
>> David
>>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---