class_docstr: deals with inheritance and many-to-many relationships
class_docstr_tok: ["deals","with","inheritance","and","many-to-many","relationships"]
code: def test_advanced(self):
      class Foo:
          def __init__(self, data=None):
              self.data = data
  
          def __repr__(self):
              return "Foo id %d, data %s" % (self.id, self.data)
  
      self.mapper_registry.map_imperatively(Foo, foo)
  
      class Bar(Foo):
          def __repr__(self):
              return "Bar id %d, data %s" % (self.id, self.data)
  
      self.mapper_registry.map_imperatively(Bar, bar, inherits=Foo)
  
      class Blub(Bar):
          def __repr__(self):
              return "Blub id %d, data %s, bars %s, foos %s" % (
                  self.id,
                  self.data,
                  repr([b for b in self.bars]),
                  repr([f for f in self.foos]),
              )
  
      self.mapper_registry.map_imperatively(
          Blub,
          blub,
          inherits=Bar,
          properties={
              "bars": relationship(
                  Bar, secondary=blub_bar, lazy="joined"
              ),
              "foos": relationship(
                  Foo, secondary=blub_foo, lazy="joined"
              ),
          },
      )
  
      sess = fixture_session()
      f1 = Foo("foo #1")
      b1 = Bar("bar #1")
      b2 = Bar("bar #2")
      bl1 = Blub("blub #1")
      for o in (f1, b1, b2, bl1):
          sess.add(o)
      bl1.foos.append(f1)
      bl1.bars.append(b2)
      sess.flush()
      compare = repr(bl1)
      blubid = bl1.id
      sess.expunge_all()
  
      result = sess.query(Blub).all()
      print(result)
      self.assert_(repr(result[0]) == compare)
      sess.expunge_all()
      x = sess.query(Blub).filter_by(id=blubid).one()
      print(x)
      self.assert_(repr(x) == compare)
  
imports: from sqlalchemy import Column
  from sqlalchemy import ForeignKey
  from sqlalchemy import Integer
  from sqlalchemy import Sequence
  from sqlalchemy import String
  from sqlalchemy import Table
  from sqlalchemy.orm import class_mapper
  from sqlalchemy.orm import relationship
  from sqlalchemy.testing import config
  from sqlalchemy.testing import eq_
  from sqlalchemy.testing import fixtures
  from sqlalchemy.testing.fixtures import fixture_session
  from sqlalchemy.testing.provision import normalize_sequence
label_desc: Use image node_id 3 for calling the InheritTest3 obj's underlying member method code with example usage: obj.test_advanced() and returns: unknown, unknown, unknown