I have a single-table inheritance setup:

class Device(Base):
  __tablename__ = 'devices'
  devtype = Column(Unicode(20), nullable = False)
  mac = Column(Unicode(128), primary_key = True)
  ...

class PC(Device):
  __mapper_args_ = {'polymorphic_identity':u'PC'}
  switch_mac = Column(Unicode(128), ForeignKey(mac), nullable = True) #
ignore any typos here - this is munged code

class Switch(Device):
  __mapper_args_ = {'polymorphic_identity':u'Switch'}
  ...

pc_ct_subq = select([func.count(PC.mac)]).where(PC.switch_mac ==
Switch.mac).as_scalar()
Switch.pc_ct = column_property(pc_ct_subq)

When I didn't have the inheritance set up (when Switch and PC were separate
tables and separate objects), pc_ct worked fine. Now, however, it's failing
- I think because the inheritance is appending "AND devices.devtype IN 'AP'"
to the initial load query since it's trying to bring up just devices of type
'Switch'.

How do I get around this? I just want Switch to have an attribute that
represents the number of PCs that are associated to it (where the PC's
switch_mac equals the Switch's mac).

Thanks,

S.

-- 
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.

Reply via email to