Skip to content

Commit a12b199

Browse files
committed
Add documentation for multilink expression syntax
1 parent 1fc802a commit a12b199

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

doc/customizing.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,6 +2985,28 @@ filter lists of items from this class, filtered and sorted. Two
29852985
``issue.filter(filterspec={"priority": "1",
29862986
'messages.creation' : '.-1w;'}, sort=[('activity', '+')])``
29872987

2988+
Note that when searching for Link and Multilink values, the
2989+
special value '-1' searches for empty Link or Multilink
2990+
values. For both, Links and Multilinks, multiple values
2991+
given in a filter call are combined with 'OR' by default.
2992+
For Multilinks a postfix expression syntax using negative ID
2993+
numbers (as strings) as operators is supported. Each
2994+
non-negative number (or '-1') is pushed on an operand stack.
2995+
A negative number pops the required number of arguments from
2996+
the stack, applies the operator, and pushes the result. The
2997+
following operators are supported:
2998+
- '-2' stands for 'NOT' and takes one argument
2999+
- '-3' stands for 'AND' and takes two arguments
3000+
- '-4' stands for 'OR' and takes two arguments
3001+
Note that this special handling of ID arguments is applied only
3002+
when a negative number smaller than -1 is encountered as an ID
3003+
in the filter call. Otherwise the implicit OR default
3004+
applies.
3005+
Examples of using Multilink expressions would be
3006+
- '1', '2', '-4', '3', '4', '-4', '-3'
3007+
would search for IDs (1 or 2) and (3 or 4)
3008+
- '-1' '-2' would search for all non-empty Multilinks
3009+
29883010
filter_sql **Only in SQL backends**
29893011

29903012
Lists the items that match the SQL provided. The SQL is a

roundup/hyperdb.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,25 @@ def filter(self, search_matches, filterspec, sort=[], group=[],
17011701
make sense to specify multiple values because those cannot all
17021702
be matched exactly.
17031703
1704+
For Link and Multilink properties the special ID value '-1'
1705+
matches empty Link or Multilink fields. For Multilinks a postfix
1706+
expression syntax using negative ID numbers (as strings) as
1707+
operators is supported. Each non-negative number (or '-1') is
1708+
pushed on an operand stack. A negative number pops the required
1709+
number of arguments from the stack, applies the operator, and
1710+
pushes the result. The following operators are supported:
1711+
- -2 stands for 'NOT' and takes one argument
1712+
- -3 stands for 'AND' and takes two arguments
1713+
- -4 stands for 'OR' and takes two arguments
1714+
Note that this special handling of ID arguments is applied only
1715+
when a negative number smaller than -1 is encountered as an ID
1716+
in the filter call. Otherwise the implicit OR default applies.
1717+
Examples of using Multilink expressions would be
1718+
- '1', '2', '-4', '3', '4', '-4', '-3'
1719+
would search for IDs (1 or 2) and (3 or 4)
1720+
- '-1' '-2' would search for all non-empty Multilinks
1721+
1722+
17041723
The propname in filterspec and prop in a sort/group spec may be
17051724
transitive, i.e., it may contain properties of the form
17061725
link.link.link.name, e.g. you can search for all issues where a

0 commit comments

Comments
 (0)