summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-12-11 23:55:10 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-12-11 23:55:10 -0500
commit57b95f45536e1f9c4450d118f0fb2534606b6f2a (patch)
tree4f78bad14c2b3aa6e55fa927cdb31e663e8b20a1 /lib/sqlalchemy
parent1f85fe62300a1c6cf69fe6f2ef2d4e360b5f3a58 (diff)
downloadsqlalchemy-57b95f45536e1f9c4450d118f0fb2534606b6f2a.tar.gz
slight shrinking of the iterable
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/interfaces.py17
-rw-r--r--lib/sqlalchemy/orm/strategies.py2
2 files changed, 10 insertions, 9 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py
index 127f070cc..2a9d3760b 100644
--- a/lib/sqlalchemy/orm/interfaces.py
+++ b/lib/sqlalchemy/orm/interfaces.py
@@ -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:
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index f23145da5..1cea5349a 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -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)