def test_selectinload_query(self): session = ShardedSession(shards={"test": testing.db}, shard_chooser=lambda *args: 'test', id_chooser=lambda *args: None, query_chooser=lambda *args: ['test']) Book, Page = self.classes("Book", "Page") book = Book() book.pages.append(Page()) session.add(book) session.commit() result = session.query(Book).options(selectinload('pages')).all() eq_(result, [book])
def test_selectinload_query(self): session = ShardedSession( shards={"test": testing.db}, shard_chooser=lambda *args: 'test', id_chooser=lambda *args: None, query_chooser=lambda *args: ['test'] ) Book, Page = self.classes("Book", "Page") book = Book() book.pages.append(Page()) session.add(book) session.commit() result = session.query(Book).options(selectinload('pages')).all() eq_(result, [book])
def test_lazy_load_from_identity_map(self): session = ShardedSession(shards={"test": testing.db}, shard_chooser=lambda *args: 'test', id_chooser=lambda *args: ['test'], query_chooser=lambda *args: ['test']) Book, Page = self.classes("Book", "Page") book = Book() book.pages.append(Page()) session.add(book) session.commit() book = session.query(Book).first() page = session.query(Page).first() def go(): eq_(page.book, book) # doesn't emit SQL self.assert_sql_count(testing.db, go, 0)