[sqlalchemy] Problem with SAWarning: Multiple rows returned with uselist=False

2011-04-07 Thread Aleksander Siewierski

Hi, in part of my model I have a TaskIntro item and RedirectRule item
connected with relation one-to-one one-sided, mapper for TaskIntro
looks like:

mapper(
TaskIntro,
table,
version_id_col = table.c.version ,
properties={
 ...
'redirect_rule': relation( RedirectRule,
 cascade=all, delete,
 primaryjoin=table.c.redirect_rule_id ==
redirect_rule_t.c.id
 ),
...
}

and when I call method that get TaskIntro defined:
def _get_all_query(self, **kwargs):
query = self.query.options(
contains_eager('redirect_rule'),
eagerload_all('redirect_rule.periods'),
eagerload('redirect_rule.channels'),
...
)
return query

I receive following warning:
/usr/lib/python2.6/dist-packages/sqlalchemy/orm/mapper.py:2113:
SAWarning: Multiple rows returned with uselist=False for eagerly-
loaded attribute 'TaskIntro.redirect_rule'
  populator(state, dict_, row)

I'm googling about this warning, but have no idea what this can mean.
How can multiple rows be returned here?

What is interesting, this following warning appears in SQLAlchemy
0.6.3-2, but on earlier version doesn't.


-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Problem with SAWarning: Multiple rows returned with uselist=False

2011-04-07 Thread Michael Bayer

On Apr 7, 2011, at 11:07 AM, Aleksander Siewierski wrote:

 
 Hi, in part of my model I have a TaskIntro item and RedirectRule item
 connected with relation one-to-one one-sided, mapper for TaskIntro
 looks like:
 
 mapper(
TaskIntro,
table,
version_id_col = table.c.version ,
properties={
 ...
'redirect_rule': relation( RedirectRule,
 cascade=all, delete,
 primaryjoin=table.c.redirect_rule_id ==
 redirect_rule_t.c.id
 ),
...
}
 
 and when I call method that get TaskIntro defined:
 def _get_all_query(self, **kwargs):
query = self.query.options(
contains_eager('redirect_rule'),
eagerload_all('redirect_rule.periods'),
eagerload('redirect_rule.channels'),
...
)
return query
 
 I receive following warning:
 /usr/lib/python2.6/dist-packages/sqlalchemy/orm/mapper.py:2113:
 SAWarning: Multiple rows returned with uselist=False for eagerly-
 loaded attribute 'TaskIntro.redirect_rule'
  populator(state, dict_, row)
 
 I'm googling about this warning, but have no idea what this can mean.
 How can multiple rows be returned here?

You didn't put a full example or the query you're using so its impossible to 
give a specific answer.   But it means the way you're joining from TaskIntro to 
RedirectRule in your query is incorrect such that multiple RedirectRule rows 
are being returned corresponding to a single TaskIntro identity.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.