code
stringlengths
3
6.57k
test_eq_ne(self)
fixture_session()
sess.query(Node)
filter(Node.data == "n12")
one()
sess.query(Node)
filter(Node.parent == n12)
all()
Node(data="n121")
Node(data="n122")
Node(data="n123")
sess.query(Node)
filter(Node.parent != n12)
all()
Node(data="n1")
Node(data="n11")
Node(data="n12")
Node(data="n13")
SelfReferentialM2MTest(fixtures.MappedTest)
define_tables(cls, metadata)
Column("data", String(30)
ForeignKey("nodes.id")
ForeignKey("nodes.id")
setup_classes(cls)
Node(cls.Comparable)
insert_data(cls, connection)
Session(connection)
Node(data="n1")
Node(data="n2")
Node(data="n3")
Node(data="n4")
Node(data="n5")
Node(data="n6")
Node(data="n7")
sess.add(n1)
sess.add(n2)
sess.add(n3)
sess.add(n4)
sess.flush()
sess.close()
test_any(self)
fixture_session()
sess.query(Node)
filter(Node.children.any(Node.data == "n3")
order_by(Node.data)
all()
Node(data="n1")
Node(data="n2")
test_contains(self)
fixture_session()
sess.query(Node)
filter_by(data="n4")
one()
sess.query(Node)
filter(Node.children.contains(n4)
order_by(Node.data)
all()
Node(data="n1")
Node(data="n3")
sess.query(Node)
filter(not_(Node.children.contains(n4)
order_by(Node.data)
all()
Node(data="n2")
Node(data="n4")
Node(data="n5")
Node(data="n6")
Node(data="n7")
test_explicit_join(self)
fixture_session()
aliased(Node)
sess.query(Node)
select_from(join(Node, n1, "children")
filter(n1.data.in_(["n3", "n7"])
order_by(Node.id)
all()
Node(data="n1")
Node(data="n2")
JoinLateralTest(fixtures.MappedTest, AssertsCompiledSQL)
default.DefaultDialect(supports_native_boolean=True)
define_tables(cls, metadata)
Column("people_id", Integer, primary_key=True)
Column("age", Integer)
Column("name", String(30)
Column("bookcase_id", Integer, primary_key=True)
ForeignKey("people.people_id")
Column("bookcase_shelves", Integer)
Column("bookcase_width", Integer)
Column("book_id", Integer, primary_key=True)
ForeignKey("bookcases.bookcase_id")
Column("book_owner_id", Integer, ForeignKey("people.people_id")
Column("book_weight", Integer)
setup_classes(cls)
Person(cls.Comparable)
Bookcase(cls.Comparable)
Book(cls.Comparable)
setup_mappers(cls)
cls.classes("Person", "Bookcase", "Book")
cls.tables("people", "bookcases", "books")
cls.mapper_registry.map_imperatively(Person, people)