A semantic search engine for source code https://bitshift.benkurtovic.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
965 B

  1. __all__ = ["Tree"]
  2. class Tree(object):
  3. """Represents a query tree."""
  4. def __init__(self, root):
  5. self._root = root
  6. def __repr__(self):
  7. return "Tree({0})".format(self._root)
  8. @property
  9. def root(self):
  10. """The root node of the tree."""
  11. return self._root
  12. def sortkey(self):
  13. """Return a string sort key for the query tree."""
  14. return self._root.sortkey()
  15. def serialize(self):
  16. """Create a string representation of the query for caching.
  17. :return: Query string representation.
  18. :rtype: str
  19. """
  20. return repr(self)
  21. def parameterize(self):
  22. """Parameterize the query tree for an SQL SELECT statement.
  23. :return: SQL query data.
  24. :rtype: 3-tuple of (query conditional string, table set, param tuple)
  25. """
  26. conditional, tables, arglist = self._root.parameterize(set())
  27. return conditional, tables, tuple(arglist)