Return a sql string representation of the given object.
(self, object_)
| 468 | for values_row in values_clause.values_rows])) |
| 469 | |
| 470 | def _write(self, object_): |
| 471 | '''Return a sql string representation of the given object.''' |
| 472 | # What's below is effectively a giant switch statement. It works based on a func |
| 473 | # naming and signature convention. It should match the incoming object with the |
| 474 | # corresponding func defined, then call the func and return the result. |
| 475 | # |
| 476 | # Ex: |
| 477 | # a = model.And(...) |
| 478 | # _write(a) should call _write_func(a) because "And" is a subclass of "Func" and no |
| 479 | # other _writer_<class name> methods have been defined higher up the method |
| 480 | # resolution order (MRO). If _write_and(...) were to be defined, it would be called |
| 481 | # instead. |
| 482 | for type_ in getmro(type(object_)): |
| 483 | writer_func_name = '_write_' + self._to_py_name(type_.__name__) |
| 484 | writer_func = getattr(self, writer_func_name, None) |
| 485 | if writer_func: |
| 486 | return writer_func(object_) |
| 487 | |
| 488 | # Handle any remaining cases |
| 489 | if isinstance(object_, Query): |
| 490 | return self.write_query(object_) |
| 491 | |
| 492 | raise Exception('Unsupported object: %s<%s>' % (type(object_).__name__, object_)) |
| 493 | |
| 494 | def get_nulls_order(self, order): |
| 495 | if self.nulls_order_asc is None: |
no test coverage detected