test #7752
(self, decl_base, connection)
| 701 | ) |
| 702 | |
| 703 | def test_no_name_declarative_two(self, decl_base, connection): |
| 704 | """test #7752""" |
| 705 | |
| 706 | class Point: |
| 707 | def __init__(self, x, y): |
| 708 | self.x = x |
| 709 | self.y = y |
| 710 | |
| 711 | def __composite_values__(self): |
| 712 | return self.x, self.y |
| 713 | |
| 714 | def __repr__(self): |
| 715 | return "Point(x=%r, y=%r)" % (self.x, self.y) |
| 716 | |
| 717 | def __eq__(self, other): |
| 718 | return ( |
| 719 | isinstance(other, Point) |
| 720 | and other.x == self.x |
| 721 | and other.y == self.y |
| 722 | ) |
| 723 | |
| 724 | def __ne__(self, other): |
| 725 | return not self.__eq__(other) |
| 726 | |
| 727 | class Vertex: |
| 728 | def __init__(self, start, end): |
| 729 | self.start = start |
| 730 | self.end = end |
| 731 | |
| 732 | @classmethod |
| 733 | def _generate(self, x1, y1, x2, y2): |
| 734 | """generate a Vertex from a row""" |
| 735 | return Vertex(Point(x1, y1), Point(x2, y2)) |
| 736 | |
| 737 | def __composite_values__(self): |
| 738 | return ( |
| 739 | self.start.__composite_values__() |
| 740 | + self.end.__composite_values__() |
| 741 | ) |
| 742 | |
| 743 | class HasVertex(decl_base): |
| 744 | __tablename__ = "has_vertex" |
| 745 | id = Column(Integer, primary_key=True) |
| 746 | x1 = Column(Integer) |
| 747 | y1 = Column(Integer) |
| 748 | x2 = Column(Integer) |
| 749 | y2 = Column(Integer) |
| 750 | |
| 751 | vertex = composite(Vertex._generate, x1, y1, x2, y2) |
| 752 | |
| 753 | self.assert_compile( |
| 754 | select(HasVertex), |
| 755 | "SELECT has_vertex.id, has_vertex.x1, has_vertex.y1, " |
| 756 | "has_vertex.x2, has_vertex.y2 FROM has_vertex", |
| 757 | ) |
| 758 | |
| 759 | decl_base.metadata.create_all(connection) |
| 760 | s = Session(connection) |
nothing calls this directly
no test coverage detected