simplify entity_name

Issue #1112 resolved
Mike Bayer repo owner created an issue

We're going to reduce entity_name to this:

mapper(Foo, foo_table, entity_name="bar")

    .... in mapper:

            # make our own subclass for this entity_name
            self.class_ = type("Foo", (Foo,) {})


f = Foo()
session.add(f, entity_name="bar")

      ... in Session:

           # change the class of the incoming object
           cls = class_mapper(f.__class__, entity_name="bar").class_
           f.__class__ = cls


foo_entity = entity(Foo, entity_name="bar")
sess.query(foo_entity).filter(foo_entity.id==5)

     ... in entity()

          # return class_mapper(Foo, entity_name="bar").class_

the step where we call type() also needs to take the class' metaclass into account.

Comments (2)

  1. Log in to comment