| 42 | == Field Selectors == |
| 43 | |
| 44 | S3ResourceQuery instances are based on S3QueryField field selectors. A field selector is a string with the so-called "list_fields syntax": |
| 45 | |
| 46 | {{{ |
| 47 | alias.{foreign key$}field |
| 48 | }}} |
| 49 | |
| 50 | - '''alias''' is the alias of the component without prefix, e.g. "contact" for the pr_contact component (note that components may use aliases different from their table name). For the primary table of a resource (master table), "alias" is just the tablename without prefix. |
| 51 | - '''foreign key''' is the name of a foreign key field in the table specified by ''alias'', both together addressing the table referenced by this foreign key. It is possible to chain foreign key selectors to address tables which are more than one reference level away. Note that only real foreign key fields can be used (i.e. neither integer fields nor virtual fields). |
| 52 | - '''field''' is the name of the field or a virtual field in the table addressed by ''alias'' (plus ''foreign key'' where present). |
| 53 | |
| 54 | With this syntax, it is possible to address fields in the primary table, in component tables and in directly referenced tables. |
| 55 | |
| 56 | It is not yet possible to address fields in tables linked by link tables - this is though subject to change in the near future. |
| 57 | |
| 60 | Filters can be specified in URLs simply by adding URL query variables in the form: |
| 61 | |
| 62 | {{{ |
| 63 | <field selector>__<operator>=<value> |
| 64 | }}} |
| 65 | |
| 66 | (Note: these are two underscores between field selector and operator) |
| 67 | |
| 68 | The following operators are supported: |
| 69 | |
| 70 | ||'''Operator'''||'''Meaning'''||'''Comment'''|| |
| 71 | ||lt||less than|||| |
| 72 | ||le||less or equal|||| |
| 73 | ||eq||equal||can be omitted (=default)|| |
| 74 | ||ne||not equal|||| |
| 75 | ||ge||greater or equal|||| |
| 76 | ||gt||greater than|||| |
| 77 | ||contains||containment||given value belongs to field value (which is a list)|| |
| 78 | ||belongs||reverse containment||field value belongs to a list of given values|| |
| 79 | ||like||string containment||case-insensitive|| |
| 80 | |
| 81 | No negate an operator, simply append a ! to the operator like in: |
| 82 | |
| 83 | {{{ |
| 84 | ?person.first_name__like!=Dominic |
| 85 | }}} |
| 86 | |
| 87 | The '''value''' can be a single value, a comma-separated list of values. NONE specifies a null-value (undefined, Python None). Values in quotes are treated as strings, i.e. |
| 88 | |
| 89 | {{{ |
| 90 | ?person.gender=NONE |
| 91 | }}} |
| 92 | |
| 93 | specifies the value {{{None}}}, whereas |
| 94 | |
| 95 | {{{ |
| 96 | ?person.gender="NONE" |
| 97 | }}} |
| 98 | |
| 99 | specifies the string "NONE". |
| 100 | |
| 101 | It is currently not possible to escape quotation marks in order to enclose them in strings - thus strings must not contain quotation marks. |
| 102 | |
| 103 | For all operators except __belongs, any comma-separated lists of values are treated as alternatives (OR) ''unless'' the field contains a list as well. All operators except __like are case-sensitive. |
| 104 | |