[sqlalchemy] Re: Assign mapper many-to-many with extra columns

2007-02-04 Thread Jorge Godoy

iain duncan [EMAIL PROTECTED] writes:

 On Sat, 2007-03-02 at 18:44 -0500, Karl Guertin wrote:
 On 2/3/07, iain duncan [EMAIL PROTECTED] wrote:
  InvalidRequestError: Given column 'page_article.ordering', attached to
  table 'page_article', failed to locate a corresponding column from table
  'article_36c9'
 
 I'd think that you're missing the .c. in the middle:
 
 page_article.c.ordering

 Nope, just tried again. The mappers are this:

 assign_mapper( session.context, Page_Article, page_article_table )
 assign_mapper( session.context, Article, article_table ) 

 assign_mapper(session.context, Page, page_table, properties = {
articles: relation(Article, secondary=page_article_table,
order_by=page_article_table.c.ordering,
 backref=pages, lazy=False)})

 And the error message is still:
 InvalidRequestError: Given column 'page_article.ordering', attached to
 table 'page_article', failed to locate a corresponding column from table
 'article_61f0'

A hint might be that the error message has no c in it.  If you put it there,
then the error might be generated somewhere else or be dependent on something
that is not exactly where you're changing your code.

-- 
Jorge Godoy  [EMAIL PROTECTED]


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



[sqlalchemy] Re: Assign mapper many-to-many with extra columns

2007-02-03 Thread iain duncan

On Fri, 2007-02-02 at 21:41 -0500, Karl Guertin wrote:
 Did my suggestion of dropping 'ordering' off of the article and adding
 an order_by clause to the relation not work?
 
 # article mapper
 assign_mapper( session.context, Article, article_table)
 
 # page mapper with m-to-m relation on articles
 assign_mapper(session.context, Page, page_table, properties = {
articles: relation(Article, secondary=page_article_table,
order_by=page_article_table.c.ordering,
 backref=pages, lazy=False)})
 
 assign_mapper( session.context, Page_Article, page_article_table )
 

No, I got this error message:

InvalidRequestError: Given column 'page_article.ordering', attached to
table 'page_article', failed to locate a corresponding column from table
'article_36c9'


Thanks,
Iain




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



[sqlalchemy] Re: Assign mapper many-to-many with extra columns

2007-02-03 Thread Karl Guertin

On 2/3/07, iain duncan [EMAIL PROTECTED] wrote:
 InvalidRequestError: Given column 'page_article.ordering', attached to
 table 'page_article', failed to locate a corresponding column from table
 'article_36c9'

I'd think that you're missing the .c. in the middle:

page_article.c.ordering

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



[sqlalchemy] Re: Assign mapper many-to-many with extra columns

2007-02-03 Thread iain duncan

On Sat, 2007-03-02 at 18:44 -0500, Karl Guertin wrote:
 On 2/3/07, iain duncan [EMAIL PROTECTED] wrote:
  InvalidRequestError: Given column 'page_article.ordering', attached to
  table 'page_article', failed to locate a corresponding column from table
  'article_36c9'
 
 I'd think that you're missing the .c. in the middle:
 
 page_article.c.ordering

Nope, just tried again. The mappers are this:

assign_mapper( session.context, Page_Article, page_article_table )
assign_mapper( session.context, Article, article_table ) 

assign_mapper(session.context, Page, page_table, properties = {
   articles: relation(Article, secondary=page_article_table,
   order_by=page_article_table.c.ordering,
backref=pages, lazy=False)})

And the error message is still:
InvalidRequestError: Given column 'page_article.ordering', attached to
table 'page_article', failed to locate a corresponding column from table
'article_61f0'

I am sure that I have dropped all tables, re-run the tg-admin sql create
command, and restarted the shell with fresh imports. 

It looks like association proxy is what I need, so I've been spending
the day reading the SA docs thoroughly. Brain is full!

Thanks for the help
Iain


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