oh, that. OK, in the 0.4 series you'd want to set
"polymorphic_fetch='deferred'" on your mapper. Just leave it that
way, as the "non-deferred" behavior has been removed from 0.5 anyway
(its deferred in all cases). The second table will be fetched as
needed.
if you're depending heavily on inheritance I strongly recommend
looking at 0.5, this is one area where a significant amount of work
has been done.
On Aug 25, 2008, at 11:24 AM, ml wrote:
>
> 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
-~----------~----~----~----~------~----~------~--~---