Beispiel #1
0
 def join(self,
          table: Table,
          on: EXPRESSION_TYPE = None,
          using: Column = None,
          full_cartesian: bool = False):
     join = "join {table}".format(table=table.str())  # unsafe formatting
     assert on is None or using is None, "both 'on' and 'using' cannot be specified at the same time"
     if on is not None:
         join += " on {on}".format(on=ExpressionParser.parse(on).str())
     elif using is not None:
         join += " using ({using})".format(using=using.name)
     elif not full_cartesian:
         raise Exception(
             "Trying to create a join without adding 'on' nor 'using' clauses. "
             "This results in a full cartesian product of both tables, "
             "and that is probably not what you want to achieve. "
             "To avoid it, set either an 'on' condition or a 'using' column. "
             "If you really want to perform the full cartesian product, "
             "set the 'full_cartesian' parameter to true.")
     if self._not_none(self._join):
         self._join += " " + join
     else:
         self._join = join
     return self
Beispiel #2
0
 def table(self, table: Table):
     self._from = "from {table}".format(
         table=table.str())  # unsafe formatting
     return self
Beispiel #3
0
 def table(self, table: Table):
     self._table = table.str()
     return self