Hi,
I'm new to sqlalchemy though I've used other ORMs (e.g. Hibernate) before,
and I'm trying to use the new automap feature.
However it seems to be using the foreign table name rather than a suffixed
version of the column name when naming relationships. Is there a reason
for doing it this way?
SQL (using postgres 9.3, psycopg2):
CREATE TABLE room (
id serial NOT NULL PRIMARY KEY,
name varchar(80) NOT NULL,
left_neighbor integer REFERENCES room(id),
right_neighbor integer REFERENCES room(id)
);
CREATE TABLE location (
id serial NOT NULL PRIMARY KEY,
room integer NOT NULL REFERENCES room(id),
description varchar(200) NOT NULL
);
This gave me on automap_base().prepare():
sqlalchemy.exc.ArgumentError: WARNING: when configuring property 'room' on
Mapper|location|location, column 'room' conflicts with property
'<RelationshipProperty at 0x10267ba10; room>'.
After temporarily renaming the 'location.room' column to 'roomx', it loaded
and I found I could see a room attribute on the auto-created Location
class. However with the Room class itself there is a problem, since I have
two self references. This appears to create room and room_collection
attributes. I haven't experimented to see which/how these get filled in
for instances, but clearly the desired distinction between 'left' and
'right' neighbors is lost.
If the naming needs to be done this way for general consistency with how
things are done elsewhere in sqlalchemy, is there any way I can override
it, preferably by monkeying on the DB side (explicit naming of foreign key
constraints, etc.), not manually tweaking on the python side (which would
defeat the purpose of using automap)?
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.