Source code:
from lino.apps.contacts.contacts_demo import startup from lino.apps.contacts.contacts_tables import Nation from lino.adamo.filters import NotEmpty dbc = startup(big=True) qry=dbc.query(Nation,"id name") qry.addColumn("cities",search="dre",orderBy="name",depth=1) qry.addColFilter('cities',NotEmpty) qry.show( columnWidths="2 15 *", title="Nations and their Cities containing search string 'dre'") print print qry.getSqlSelect() del dbc, qry
Output:
Nations and their Cities containing search string 'dre' ======================================================= id|name |cities --+---------------+---------------------------------------- be|Belgium |Audregnies (be), Berendrecht (be), | |Drehance (be), Gondregnies (be), | |Houdremont (be), Jandrain-Jandrenouille | |(be), Kieldrecht (be), Merendree (be), | |Mont-Saint-Andre (be), Saint-Andre (be), | |Wandre (be), Warnant-Dreye (be), Waudrez | |(be), Xhendremael (be), Zwijndrecht (be) de|Germany |Drebkau (de), Dreieich (de), | |Drensteinfurt (de), Dresden (de), Sankt | |Andreasberg, Bergstadt (de) SELECT id, name_en FROM Nations WHERE EXISTS (SELECT * FROM Cities WHERE nation_id=Nations.id AND name LIKE '%dre%' OR zipCode LIKE '%dre%' ORDER BY name)
Refering articles:
- filters1.py needs DetailColumn (code changes 04.03.06) — I noticed that filters1.py and filters2.py show a rather serious problem of the new paradigm for handling details. It sets a filter on a detail column. But I thought such columns to disappear. How can I convert filters1.py to the new paradigm? Answer: DetailColumn remains.
- Marking an example "todo" (05.09.05) — I modified 32 to recognize a "TODO:" string in the output of examples. Because filters2.py also suffers from Crash in big addrbook demo (29.08.05) more
- filters on subqueries: first success (06.05.05) — Uff! Filtering on subqueries (see examples filters1.py and filters2.py) works finally. Soon I will use this for Keeper.