On Jul 12, 2013, at 12:49 PM, Alexandre Torres <alexandre.tor...@gmail.com> 
wrote:

> Hi,
> 
> I have the following concrete inheritance structure (simplified in fact...)
> 
> A <-- B <-- L1
> A <-- C <-- L2
> 
> Where L1 and L2 have tables (T1, T2).
> 
> using declarative, I could define classes A,B and C as AbstractConcreteBase, 
> and therefore issue polymorphic queries including L1,L2 (and any other 
> concrete leaf).
> 
> Right?
> 
> The problem here is how can I do the same using the Classical Mappings?
> The mapper requires a Table mapping for the root classes A,B,C. But they 
> don't exist. 

concrete mappings are much easier with classical mappings in this regard, since 
all the Table objects are already available when you call upon mapper().

Basically, you'd follow the example that's in the current docs here: 
http://docs.sqlalchemy.org/en/rel_0_8/orm/inheritance.html#concrete-table-inheritance
 , but the base "employee_mapper", you map it directly to the "pjoin" 
selectable.


> I took a look in the source, but it is a little difficult to understand. 
> Should I declare mappers for A,B and C? but if I don't declare, I will not be 
> able to query...
> the AbstractConcreteBase implementation kind of intruduces some kind of later 
> mapping I could not figure out.

ABC is going through a lot of hoops to work out the out-of-order nature of an 
abstract concrete base.   Other than the convenience of declarative in other 
areas, concrete mappings are easier to structure using classical mappers.


> 
> It just looks like the classical thing is going to be aborted.

What gives you that impression?   The entire ORM is built upon mapper(), that's 
the most fundamental feature of the whole library.  Declarative is just an 
extension on top of it (hence its under sqlalchemy.ext).    The vast majority 
of users don't want to deal with mapper() on a regular basis (including myself) 
but it is certainly the cornerstone of the whole system and would never go 
anywhere.   See 
http://docs.sqlalchemy.org/en/rel_0_8/orm/mapper_config.html#classical-mappings 
for some detail on this system.




-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to