0

how to use OR in filters?

eg:

filters = [['project','is', {'type': 'Project','id': pid}],['entity','is',{'type':'Shot','id':sid}],['step.Step.content', 'is', stepname],['step.Step.content', 'is', otherstepname]]

...is stepname and otherstepname.
how would I say stepname or otherstepname ?

2件のコメント

  • 0
    Avatar
    Tony Aiello

    Well, first, there is no `content` field on Pipeline Steps -- the step name field is `code`.  `content` is the Task Name field.

    Filters can be tuples or lists or dicts.  To do an OR filter, you use a dict with a `filter_operator` key and a `filters` key, like so:

    filters = [

        ('project', 'is', {'type': 'Project', 'id': pid}),

        ('entity', 'is', {'type': 'Shot', 'id': sid),

        {'filter_operator': 'any', 'filters': [  # 'any' == 'or', otherwise assumed default is 'all'

            ('step.Step.code', 'is', stepname),

            ('step.Step.code', 'is', otherstepname),

        ]},

    ]

     

    However, filter syntax include the `in` operator, so you don't need an `any` operator.  You can just do:

        ('step.Step.code', 'in', [stepname, otherstepname])

     

    Cheers

  • 0
    Avatar
    craig brown

    perfect, thanks Tony.

ログインしてコメントを残してください。