def test_many_to_one_null(self):

        Order, Address, addresses, orders = (self.classes.Order,
                                             self.classes.Address,
                                             self.tables.addresses,
                                             self.tables.orders)

        # use a primaryjoin intended to defeat SA's usage of
        # query.get() for a many-to-one lazyload
        mapper(Order, orders, properties=dict(
            address=relationship(
                mapper(Address, addresses),
                primaryjoin=and_(
                    addresses.c.id == orders.c.address_id,
                    addresses.c.email_address != None
                ),

                lazy='joined')
        ))
        sess = create_session()

        def go():
            o1 = sess.query(Order).options(
                lazyload('address')).filter(
                Order.id == 5).one()
            eq_(o1.address, None)
        self.assert_sql_count(testing.db, go, 2)

        sess.expunge_all()

        def go():
            o1 = sess.query(Order).filter(Order.id == 5).one()
            eq_(o1.address, None)
        self.assert_sql_count(testing.db, go, 1)
Return the datafield object with name 'name' (if exists).
dataset/ETHPy150Open zzzeek/sqlalchemy/test/orm/test_eager_relations.py/EagerTest.test_many_to_one_null--crossover with--dataset/ETHPy150Open CouchPotato/CouchPotatoServer/libs/xmpp/protocol.py/DataItem.getField