I am also suspecting the 1st issue to cascade down to the rest. Here
is some stripped down code, reproducing the first issue. Please let me
know if I am doing anything wrong. Again, this works fine with 0.3.3:
###############################################
# Here is the database creation script
# (Note: I created a database called "buggy",
# on PostgreSQL 8.1)
###############################################
db_create_string = """
CREATE TABLE party (
id integer primary key,
ptype varchar(80) NOT NULL
);
CREATE TABLE wedding (
id integer primary key,
CONSTRAINT party_exists
FOREIGN KEY (id)
REFERENCES PARTY (id)
);
"""
##############################################
# Bug producing code
# (change dsn as appropriate)
##############################################
dsn = 'postgres://[EMAIL PROTECTED]:5432/buggy'
from sqlalchemy import *
metadata = BoundMetaData(dsn)
class Party(object): pass
class Enkai(Party): pass
class Tasting(Party): pass
class Wedding(Party): pass
party_table = Table('party', metadata, autoload=True)
wedding_table = Table('wedding', metadata, autoload=True)
party_join = polymorphic_union(
{
'wd': party_table.join(wedding_table),
'en': party_table.select(party_table.c.ptype=='ENKAI'),
'ta': party_table.select(party_table.c.ptype=='TASTING'),
}, None, 'pjoin')
party_mapper = mapper(Party, party_table,
select_table=party_join,
polymorphic_on=party_join.c.ptype)
mapper(Enkai, party_table,
inherits=party_mapper,
polymorphic_identity='ENKAI')
mapper(Tasting, party_table,
inherits=party_mapper,
polymorphic_identity='TASTING')
mapper(Wedding, wedding_table,
inherits=party_mapper,
polymorphic_identity='WEDDING')
dbsession = create_session()
party_query = dbsession.query(Party)
###############################################
# End of code here
###############################################
The last line of code gives me the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "build/bdist.linux-i686/egg/sqlalchemy/orm/session.py", line
203, in query
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
1470, in class_mapper
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
259, in compile
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
274, in _compile_all
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
299, in _do_compile
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
334, in _compile_inheritance
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
302, in _do_compile
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
520, in _compile_selectable
sqlalchemy.exceptions.ArgumentError: Could not locate a
polymorphic_identity field for mapper 'Mapper|Party|party'. This
field is required for polymorphic mappers
Thanks for your help.
--
Yves-Eric
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---