#2069: add an error if eagerload options etc. are called with no mapper entities
-------------------------+--------------------------------------------------
Reporter: guest | Owner: zzzeek
Type: enhancement | Status: new
Priority: low | Milestone: 0.6.7
Component: orm | Severity: minor - half an hour
Keywords: | Status_field: in queue
-------------------------+--------------------------------------------------
Comment(by guest):
2069.patch changes two basestring option cases (#5, #7) to behave the same
as the PropComparator cases.
What it still doesn't do in the basestring case, is find the correct
_MapperEntity if there is more than one (didn't before either) -- it just
returns the first _MapperEntity. I think does work in the PropComparator
case, but I didn't try it.
Below are some cases with the resulting SQL or exceptions.
{{{
Case 1: Just Mapper: basestring
session.query(Forum).options(eagerload('last_post'))
SELECT forum.id AS forum_id, forum.name AS forum_name, forum.last_post_id
AS forum_last_post_id, post_1.id AS post_1_id, post_1.name AS post_1_name
FROM forum LEFT OUTER JOIN post AS post_1 ON post_1.id =
forum.last_post_id
Case 2: Just Mapper: PropComparator
session.query(Forum).options(eagerload(Forum.last_post))
SELECT forum.id AS forum_id, forum.name AS forum_name, forum.last_post_id
AS forum_last_post_id, post_1.id AS post_1_id, post_1.name AS post_1_name
FROM forum LEFT OUTER JOIN post AS post_1 ON post_1.id =
forum.last_post_id
Case 3: Mapper + Column (in that order): basestring
session.query(Forum, Forum.id).options(eagerload('last_post'))
SELECT forum.id AS forum_id, forum.name AS forum_name, forum.last_post_id
AS forum_last_post_id, post_1.id AS post_1_id, post_1.name AS post_1_name
FROM forum LEFT OUTER JOIN post AS post_1 ON post_1.id =
forum.last_post_id
Case 4: Mapper + Column (in that order): PropComparator
session.query(Forum, Forum.id).options(eagerload(Forum.last_post))
SELECT forum.id AS forum_id, forum.name AS forum_name, forum.last_post_id
AS forum_last_post_id, post_1.id AS post_1_id, post_1.name AS post_1_name
FROM forum LEFT OUTER JOIN post AS post_1 ON post_1.id =
forum.last_post_id
Case 5: Column + Mapper (in that order): basestring <---- was:
'_ColumnEntity' object has no attribute 'path_entity'
session.query(Forum.id, Forum).options(eagerload('last_post'))
SELECT forum.id AS forum_id, forum.name AS forum_name, forum.last_post_id
AS forum_last_post_id, post_1.id AS post_1_id, post_1.name AS post_1_name
FROM forum LEFT OUTER JOIN post AS post_1 ON post_1.id =
forum.last_post_id
Case 6: Column + Mapper (in that order): PropComparator
session.query(Forum.id, Forum).options(eagerload(Forum.last_post))
SELECT forum.id AS forum_id, forum.name AS forum_name, forum.last_post_id
AS forum_last_post_id, post_1.id AS post_1_id, post_1.name AS post_1_name
FROM forum LEFT OUTER JOIN post AS post_1 ON post_1.id =
forum.last_post_id
Case 7: Just Column: basestring <---- was: '_ColumnEntity' object has
no attribute 'path_entity'
session.query(Forum.id).options(eagerload('last_post'))
Can't find entity last_post in Query. Current list: ['forum.id']
Case 8: Just Column: PropComparator
session.query(Forum.id).options(eagerload(Forum.last_post))
Can't find entity Mapper|Forum|forum in Query. Current list: ['forum.id']
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2069#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|