Thanks!!

On May 10, 2:42 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> very simple and was fixed in r4720.
>
> On May 10, 2008, at 12:48 PM, Michael Bayer wrote:
>
>
>
> > seems like a bug whereby when it sees the "Manager" single table
> > inheritor, it somehow doesn't get the message to synchronize the
> > "Employee" primary key column with the Person primary key column.
> > I'll have a look at it later today.
>
> > On May 9, 2008, at 7:49 PM, Fernando Zunino wrote:
>
> >> Hi,
> >> is it possible to combine joined and single table inheritance in the
> >> same inheritance hierarchy?
>
> >> In the code at the bottom I want to use the persons table as a base
> >> for the Person, Employee and Manager classes and the employees table
> >> to store the particular fields of Employee and Manager.
>
> >> I've run this code using PostgreSql and it correctly flushes the
> >> Person and Employee instances but when it wants to flush the Manager
> >> instance gives the following error:
>
> >> /home/fernando/.pythonrepo/SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/
> >> engine/base.py in _handle_dbapi_exception(self, e, statement,
> >> parameters, cursor)
> >>   940                 if self.__close_with_result:
> >>   941                     self.close()
> >> --> 942             raise exceptions.DBAPIError.instance(statement,
> >> parameters, e, connection_invalidated=is_disconnect)
> >>   943         finally:
> >>   944             del self._reentrant_error
>
> >> <class 'sqlalchemy.exceptions.ProgrammingError'>: (ProgrammingError)
> >> relation "employees_person_id_seq" does not exist
> >> 'select nextval(\'"employees_person_id_seq"\')' None
>
> >> Anyone have any suggestions?
>
> >> thanks,
> >> Fernando
>
> >> class Person(object):
> >>   def __init__(self, name):
> >>       self.name = name
> >>   def __repr__(self):
> >>       return self.__class__.__name__ + " " + self.name
>
> >> class Employee(Person):
> >>   def __init__(self, name, employee_data):
> >>       self.name = name
> >>       self.employee_data = employee_data
>
> >>   def __repr__(self):
> >>       return self.__class__.__name__ + " " + self.name + " " +
> >> self.employee_data
>
> >> class Manager(Employee):
> >>   def __init__(self, name, employee_data, manager_data):
> >>       self.name = name
> >>       self.employee_data = employee_data
> >>       self.manager_data = manager_data
>
> >>   def __repr__(self):
> >>       return self.__class__.__name__ + " " + self.name + " " +
> >> self.manager_data
>
> >> persons_table = Table('persons', metadata,
> >>   Column('person_id', Integer, primary_key=True),
> >>   Column('name', String(50)),
> >>   Column('type', String(20), nullable=False)
> >> )
>
> >> employees_table = Table('employees', metadata,
> >>   Column('person_id', Integer, ForeignKey('persons.person_id'),
> >> primary_key=True),
> >>   Column('employee_data', String(50)),
> >>   Column('manager_data', String(50)),
> >> )
>
> >> person_mapper = mapper(Person, persons_table, \
> >>   polymorphic_on=persons_table.c.type,
> >> polymorphic_identity='person')
> >> employee_mapper = mapper(Employee, employees_table, inherits=Person,
> >> polymorphic_identity='engineer')
> >> manager_mapper = mapper(Manager, inherits=employee_mapper,
> >> polymorphic_identity='manager')
>
> >> metadata.create_all(engine);
> >> Session = scoped_session(sessionmaker(bind=engine, autoflush=True,
> >> transactional=True))
> >> session = Session();
>
> >> session.save(Person('fer'))
> >> session.save(Employee('e', 'e1'))
> >> session.save(Manager('m', 'e2', 'm1'))
> >> session.flush()
--~--~---------~--~----~------------~-------~--~----~
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