> thats a bug which was fixed post 0.4.7p1.  Its in trunk and is for
> 0.4.8.

Great!

And back to the mapper properties. As I found it always do a
polymorphic_fetch=select-like query when dealing with mapper properties
referencing a polymorphic base. This is not very efficient. I would
prefer an union fetch. I realized that it is similar to query().get().
Example follows:

session.query(Base).with_polymorphic("*").filter(Base.id==3).first().x

results in 1 joined select:
SELECT base.id AS base_id, base.id_parent AS base_id_parent, base.kind
AS base_kind, derived.id AS derived_id, derived.x AS derived_x,
derived.id_other AS derived_id_other
FROM base LEFT OUTER JOIN derived ON derived.id = base.id
WHERE base.id = ? ORDER BY base.oid
 LIMIT 1 OFFSET 0

but session.query(Base).with_polymorphic("*").get(3).x

results in 2 selects:
SELECT base.id AS base_id, base.id_parent AS base_id_parent, base.kind
AS base_kind
FROM base
WHERE base.id = ?
SELECT derived.x AS derived_x, derived.id_other AS derived_id_other
FROM base JOIN derived ON derived.id = base.id
WHERE base.id = ?

Both queries gives the same object but the get() generates 2 selects
(like the mapper property fetch). Why?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to