Skip to content

Commit

Permalink
Substitute unquoted string for tokens in queries
Browse files Browse the repository at this point in the history
  • Loading branch information
TropicalPenguin committed Aug 6, 2017
1 parent a3e6001 commit c74cd70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pyorient/ogm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def retry(self, retries):
from .expressions import ExpressionMixin
from .property import PropertyEncoder
from .operators import LogicalConnective
from .what import QS
class RetrievalCommand(Command, ExpressionMixin):
def __init__(self, command_text=None):
self._compiled = command_text
Expand All @@ -59,9 +60,11 @@ def __str__(self):

def FORMAT_ENCODER(self, v):
if isinstance(v, RetrievalCommand):
return '({})'.format(v.compile())
return '(' + v.compile() + ')'
elif isinstance(v, LogicalConnective):
return self.filter_string(v)
elif isinstance(v, QS):
return v
else:
return PropertyEncoder.encode_value(v, self)

Expand Down
5 changes: 3 additions & 2 deletions pyorient/ogm/traverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ def build_pretty_compiler(self):
def compiler():
traverse_spaces = self._params.get('indent', 0)
traverse_idt = ' ' * traverse_spaces
target = self._target
return traverse_idt + Traverse.TEMPLATE.format(self.build_fields(tuple()),
u'(' + self._target.pretty() + ')' if isinstance(self._target, Query)
else ArgConverter.convert_to(ArgConverter.Vertex, self._target, self),
u'(' + target.pretty() + ')' if isinstance(target, Query)
else ArgConverter.convert_to(ArgConverter.Vertex, target, self),
*self.build_optional())
return compiler

4 changes: 4 additions & 0 deletions pyorient/ogm/what.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ def traverse(self, *what, **kwargs):
from .traverse import Traverse
return Traverse(None, self, *what, **kwargs)

class QS(str):
"""Query string. Unquoted string substitutes to query tokens"""
pass

class FunctionWhat(MethodWhat):
"""Derived from MethodWhat for the chain of which they might be the
beginning
Expand Down

0 comments on commit c74cd70

Please sign in to comment.