Michael,

On 09/07/2011 05:10 PM, Michael Bayer wrote:
On Sep 7, 2011, at 4:40 AM, werner wrote:

or:
Region_LV.language = sao.relationship('Language',
                   primaryjoin="Country_LV.fk_language_id==Language.id",
                   foreign_keys=[Country_LV.__table__.c.fk_language_id])

I get:
sqlalchemy.exc.ArgumentError: Column-based expression object expected for argument 
'foreign_keys'; got: 'Country_LV.fk_language_id', type<type 'str'>
this one above is the one that doesn't make any sense (also its probably how 
the relationship should be set up).
Sorry that was a copy/paste error on my part.
    Clearly x.__table__.c.somename is a Column object, not a string.   
Something is up with what you're sending it.     I've tried to reproduce with 
no luck.  See attached.   Also I don't even need the primaryjoin/foreignkeys if 
the originating Table upon which the view is based has foreign keys to the 
parent.

The additional column is in my case added in to the view as the base table doesn't have it and it is filled by the stored procedure (which combines the base table plus the localized table ...) , i.e.:

def view(name, metadata, selectable):
    t = table(name)

    for c in selectable.c:
        c._make_proxy(t)

    lc = sasql.column("stuff_id", sa.Integer)
    t.append_column(lc)

But what I had overlooked/forgotten to include was the "__mapper_args__ = {"primary_key":__table__.c.id}" line.

After adding this the relationship as shown at the beginning it works.

Thanks a lot for your answer and your patience.

Werner

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

Reply via email to