]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
slight shrinking of the iterable
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 12 Dec 2010 04:55:10 +0000 (23:55 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 12 Dec 2010 04:55:10 +0000 (23:55 -0500)
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/strategies.py
test/orm/test_query.py

index 127f070cc80b59626112b52e64982eea717a9745..2a9d3760b1c13880813c6f5ed75ca2fb618e26af 100644 (file)
@@ -22,6 +22,7 @@ from itertools import chain
 import sqlalchemy.exceptions as sa_exc
 from sqlalchemy import log, util, event
 from sqlalchemy.sql import expression
+deque = util.importlater('collections').deque
 
 mapperutil = util.importlater('sqlalchemy.orm', 'util')
 
@@ -453,7 +454,7 @@ class PropertyOption(MapperOption):
                         [str(m.path_entity) for m in query._entities]))
             else:
                 return None
-
+    
     def _get_paths(self, query, raiseerr):
         path = None
         entity = None
@@ -465,14 +466,14 @@ class PropertyOption(MapperOption):
 
         current_path = list(query._current_path)
         
-        tokens = []
-        for key in util.to_list(self.key):
-            if isinstance(key, basestring):
-                tokens += key.split('.')
-            else:
-                tokens += [key]
-        for token in tokens:
+        tokens = deque(self.key)
+        while tokens:
+            token = tokens.popleft()
             if isinstance(token, basestring):
+                sub_tokens = token.split(".", 1)
+                token = sub_tokens[0]
+                tokens.extendleft(sub_tokens[1:])
+        
                 if not entity:
                     if current_path:
                         if current_path[1] == token:
index f23145da55ab6cff6344789c0c7136413baef47b..1cea5349a966cd6bb53956f8587525a63a131560 100644 (file)
@@ -656,7 +656,7 @@ class LoadLazyAttribute(object):
             if rev.direction is interfaces.MANYTOONE and \
                         rev._use_get and \
                         not isinstance(rev.strategy, LazyLoader):
-                q = q.options(EagerLazyOption(rev.key, lazy='select'))
+                q = q.options(EagerLazyOption((rev.key,), lazy='select'))
 
         if state.load_options:
             q = q._conditional_options(*state.load_options)
index b6d9947b4c4c9de9056191b2e858b160c826e7d5..cd0deee2ecb7cd9c46bf6cba063c239086f656ad 100644 (file)
@@ -2106,5 +2106,3 @@ class OptionsTest(QueryTest):
         opt = self._option_fixture(Address.user, User.addresses)
         self._assert_path_result(opt, q, [], [])
         
-        
-