Hi All
Firstly, I know that SA does not support Postgres Inheritance "out of the box". But the concepts for concrete inheritance should allow some support, at least for what I am trying to do. I am new to SA and Python (about a month of experience here) and so I don't know if I am barking up the wrong tree. Here is what I think...
Each table has a unique "tableoid" column in Postgres. So lets assume this table structure:CREATE TABLE A (
id SERIAL Primary Key,
name text
)
CREATE TABLE B (
id SERIAL Primary Key,
name text,
language text
) INHERITS(A)
Table B uses the postgres Inherits. Now lets assume that Postgres has given table A an oid of 1, and table B an oid of 2. If I do...SELECT A.tableoid, * FROM AThen the rows that are from table B will have an oid of 2, while those from A will have an oid of 1. So this mimics a polymorphism in a way and I can use this OID as a discriminator.
Here is my question (finally): How can I accomplish this in SA using concrete inheritance and polymorphism. What I want is that when querying table A, a polymorphic call will load up the class representing B in the appropriate cases. Here follows EXACTLY what I am trying to do (and the code will follow after):
- There are three postgres tables in play: (1) A Users table, (2) An Authentications table (3) A Password_Authentications table
- Users has a foreignkey into Authorisations
- Password_Authentications is inherited from Authentications
sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'banker.id'"
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Hi Michael
Sorry, I meant distuingisher in my last response (not extuigisher). The thing is, these are nore oids, they are tableoids. The difference (I think) is that oids are row based, and tableoids are distinct for the table. So every table has a unique tableoid. This is what I have been using. When I query the parent, I keep on getting this reply for the child table:
sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'banker.id'"
The setup is that Banker inhertits from Person. They both have an id as primary key, and a name as a string, and the tableoid. Querying the tables individually works perfectly along with the tableoid.
From what I have read, this should really work. But I don't know why I am getting that error above. I think this could solve the issue. Check out tableoid, in the inheritance documentation, it says this: In some cases you might wish to know which table a particular row originated from. There is a system column called tableoid in each table which can tell you the originating table:
Michael, thank you for the great product. I don't know if I will ever get a chance to thank you personally...