For joins, matching on a list field element.

7 views
Skip to first unread message

Dave S

unread,
Mar 31, 2022, 5:38:47 AM3/31/22
to web2py-users
Imagine that I defined a pair of tables as

db.define_table('stuff',
        Field('nickname', 'string'),
        Field('durations', 'list:integer'),
         Field('tones, 'list:string'))

db.define_table('nonsense',
        Field('Chapter', 'string'),
        Field('timing', 'integer'),
        Field('norm', 'string'))

If I know a nonsense.timing I'm interested in is 10, I can find the stuff that matches with

db.(db.stuff.durations.contains(10))

and the stuff that matches a nonsense.norm of "cflat" with

db.(db.stuff.tones.contains('cflat'))

But if I want to do a join, rather than a manual iteration (or nested selects), where the stuff.durations contains a match for some nonsense.timing or where the stuff.tones contains a match for some nonsense.norm, how do I write that?

Thanks.

Dave S
/dps

Reply all
Reply to author
Forward
0 new messages