(self)
| 1849 | self.sql_count_(4, go) |
| 1850 | |
| 1851 | def test_option_propagate(self): |
| 1852 | users, items, order_items, Order, Item, User, orders = ( |
| 1853 | self.tables.users, |
| 1854 | self.tables.items, |
| 1855 | self.tables.order_items, |
| 1856 | self.classes.Order, |
| 1857 | self.classes.Item, |
| 1858 | self.classes.User, |
| 1859 | self.tables.orders, |
| 1860 | ) |
| 1861 | |
| 1862 | self.mapper_registry.map_imperatively( |
| 1863 | User, users, properties=dict(orders=relationship(Order)) |
| 1864 | ) |
| 1865 | self.mapper_registry.map_imperatively( |
| 1866 | Order, |
| 1867 | orders, |
| 1868 | properties=dict(items=relationship(Item, secondary=order_items)), |
| 1869 | ) |
| 1870 | self.mapper_registry.map_imperatively(Item, items) |
| 1871 | |
| 1872 | sess = fixture_session() |
| 1873 | |
| 1874 | oalias = aliased(Order) |
| 1875 | |
| 1876 | # this one is *really weird* |
| 1877 | # here's what the test originally had. note two different strategies |
| 1878 | # for Order.items |
| 1879 | # |
| 1880 | # opt1 = sa.orm.joinedload(User.orders, Order.items) |
| 1881 | # opt2 = sa.orm.contains_eager(User.orders, Order.items, alias=oalias) |
| 1882 | |
| 1883 | # here's how it would translate. note that the second |
| 1884 | # contains_eager() for Order.items just got cancelled out, |
| 1885 | # I guess the joinedload() would somehow overrule the contains_eager |
| 1886 | # |
| 1887 | # opt1 = Load(User).defaultload(User.orders).joinedload(Order.items) |
| 1888 | # opt2 = Load(User).contains_eager(User.orders, alias=oalias) |
| 1889 | |
| 1890 | # setting up the options more specifically works however with |
| 1891 | # both the old way and the new way |
| 1892 | opt1 = sa.orm.joinedload(User.orders, Order.items) |
| 1893 | opt2 = sa.orm.contains_eager(User.orders, alias=oalias) |
| 1894 | |
| 1895 | u1 = ( |
| 1896 | sess.query(User) |
| 1897 | .join(oalias, User.orders) |
| 1898 | .options(opt1, opt2) |
| 1899 | .first() |
| 1900 | ) |
| 1901 | ustate = attributes.instance_state(u1) |
| 1902 | assert opt1 in ustate.load_options |
| 1903 | assert opt2 not in ustate.load_options |
| 1904 | |
| 1905 | @testing.combinations( |
| 1906 | ( |
nothing calls this directly
no test coverage detected