okay i got what u want as a failure-testcase... although i am not sure if my down-refactoring will keep things equivalent - in SA terms - so i may end-up with another reason for the error. Hmmm, maybe i'll make the Thing generate the plain source of the testcases itself - as u suggested before (-:).

So foreignkey... i never understood what it is about.
Also, i noted that your relation is not lazy. Is this of any importance?

(in this case the "Manager"  version is the one that fails).
hmmm. i'm on version 0.3.3. and for me, the Employee->Employee version also fails: Column's Foreignkey is on Employee; relation is on Employee class and primaryjoin is on employee_table. It dies when attempt to access a.manager:
...
sqlalchemy.exceptions.SQLError: (OperationalError) no such column: Employee.id 'SELECT p_union.bonus AS p_union_bonus, p_union.atype AS p_union_atype, p_union.manager_id AS p_union_manager_id, p_union.name AS p_union_name, p_union.id AS p_union_id \nFROM "Employee", (SELECT CAST(NULL AS TEXT) AS bonus, anon_f706.manager_id AS manager_id, anon_f706.atype AS atype, anon_f706.id AS id, anon_f706.name AS name \nFROM (SELECT "Employee".id AS id, "Employee".name AS name, "Employee".atype AS atype, "Employee".manager_id AS manager_id \nWHERE "Employee".atype = ?) AS anon_f706 UNION ALL SELECT "Manager".bonus AS bonus, "Employee".manager_id AS manager_id, "Employee".atype AS atype, "Manager".id AS id, "Employee".name AS name \nFROM "Employee" JOIN "Manager" ON "Manager".id = "Employee".id) AS p_union \nWHERE "Employee".manager_id = ? ORDER BY p_union.oid' ['Employee', 1]

see test_case2.py

Essentialy it is a self-referential mapper being inherited.
Removing all Manager stuff (but keep a polymorphic_join over one item), and it still dies:
...
sqlalchemy.exceptions.SQLError: (OperationalError) no such column: Employee.id 'SELECT p_union.atype AS p_union_atype, p_union.manager_id AS p_union_manager_id, p_union.name AS p_union_name, p_union.id AS p_union_id \nFROM "Employee", (SELECT anon_c397.manager_id AS manager_id, anon_c397.atype AS atype, anon_c397.id AS id, anon_c397.name AS name \nFROM (SELECT "Employee".id AS id, "Employee".name AS name, "Employee".atype AS atype, "Employee".manager_id AS manager_id \nWHERE "Employee".atype = ?) AS anon_c397) AS p_union \nWHERE "Employee".manager_id = ? ORDER BY p_union.oid' ['Employee', 1]

see test_case2b.py
Of course now it's a degenerated useless case - no need for the polymorphic_join as such; without it all works.

In fact until I saw this example I didnt think there was ever a reason you'd need to use "foreignkey" right now provided the Table's had proper ForeignKeys on them (self-referential mappers use "remote_side" now).
what is this remote_side? how it applies to above ?
when i have to use remote_side and when foreign_key?

ciao
svil

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

Attachment: test_case2.py
Description: application/python

Attachment: test_case2b.py
Description: application/python

Reply via email to