The first method does it without specifying columnNames:
qry=sess.query(City) home=qry.findone(name="Eupen") self.assertEqual(home.nation.name,"Belgium")
The second method specifies "in advance" that we are interested in the joined column 'nation.name'.
qry=sess.query(City,"id name nation.name") home=qry.findone(name=Eupen) self.assertEqual(home.nation.name,"Belgium")
The first method is more resource-intensive: it uses only one instead of two SQL statements because we
Method 1 generates 2 SQL statements:
SELECT nation_id, id, name, zipCode, inhabitants FROM Cities WHERE name = 'Eupen';SELECT id, name_en, area, population, curr, isocode FROM Nations WHERE id = 'be';
Method 2 generates only one SQL statement:
SELECT lead.nation_id, lead.id, lead.name, nation.id, nation.name_en FROM Cities AS lead LEFT JOIN Nations AS nation ON (lead.nation_id = nation.id) WHERE name = 'Eupen';
(Tested in 80)
Refering articles:
- fixed test 19 (code changes 03.03.06) — Uff: the last test has been fixed, the whole suite works again (first time since 20060213. more