test #7751
(self, decl_base, connection)
| 646 | eq_(e.start, Point(None, None)) |
| 647 | |
| 648 | def test_no_name_declarative(self, decl_base, connection): |
| 649 | """test #7751""" |
| 650 | |
| 651 | class Point: |
| 652 | def __init__(self, x, y): |
| 653 | self.x = x |
| 654 | self.y = y |
| 655 | |
| 656 | def __composite_values__(self): |
| 657 | return self.x, self.y |
| 658 | |
| 659 | def __repr__(self): |
| 660 | return "Point(x=%r, y=%r)" % (self.x, self.y) |
| 661 | |
| 662 | def __eq__(self, other): |
| 663 | return ( |
| 664 | isinstance(other, Point) |
| 665 | and other.x == self.x |
| 666 | and other.y == self.y |
| 667 | ) |
| 668 | |
| 669 | def __ne__(self, other): |
| 670 | return not self.__eq__(other) |
| 671 | |
| 672 | class Vertex(decl_base): |
| 673 | __tablename__ = "vertices" |
| 674 | |
| 675 | id = Column(Integer, primary_key=True) |
| 676 | x1 = Column(Integer) |
| 677 | y1 = Column(Integer) |
| 678 | x2 = Column(Integer) |
| 679 | y2 = Column(Integer) |
| 680 | |
| 681 | start = composite(Point, x1, y1) |
| 682 | end = composite(Point, x2, y2) |
| 683 | |
| 684 | self.assert_compile( |
| 685 | select(Vertex), |
| 686 | "SELECT vertices.id, vertices.x1, vertices.y1, vertices.x2, " |
| 687 | "vertices.y2 FROM vertices", |
| 688 | ) |
| 689 | |
| 690 | decl_base.metadata.create_all(connection) |
| 691 | s = Session(connection) |
| 692 | hv = Vertex(start=Point(1, 2), end=Point(3, 4)) |
| 693 | s.add(hv) |
| 694 | s.commit() |
| 695 | |
| 696 | is_( |
| 697 | hv, |
| 698 | s.scalars( |
| 699 | select(Vertex).where(Vertex.start == Point(1, 2)) |
| 700 | ).first(), |
| 701 | ) |
| 702 | |
| 703 | def test_no_name_declarative_two(self, decl_base, connection): |
| 704 | """test #7752""" |
nothing calls this directly
no test coverage detected