Changes between Version 6 and Version 7 of S3/S3ResourceFilter


Ignore:
Timestamp:
01/31/12 13:22:41 (10 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3ResourceFilter

    v6 v7  
    4040This process supports pagination (slicing), although that would necessarily not only retrieve the requested page from the database, but all records which match the DAL query. Therefore, the virtual filters should always only be the "last mile", while the DAL query reduces the number of candidates to the necessary minimum.
    4141
     42== Field Selectors ==
     43
     44S3ResourceQuery instances are based on S3QueryField field selectors. A field selector is a string with the so-called "list_fields syntax":
     45
     46{{{
     47alias.{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
     54With this syntax, it is possible to address fields in the primary table, in component tables and in directly referenced tables.
     55
     56It is not yet possible to address fields in tables linked by link tables - this is though subject to change in the near future.
     57
    4258== URL queries ==
    4359
     60Filters 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
     68The 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
     81No negate an operator, simply append a ! to the operator like in:
     82
     83{{{
     84?person.first_name__like!=Dominic
     85}}}
     86
     87The '''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
     93specifies the value {{{None}}}, whereas
     94
     95{{{
     96?person.gender="NONE"
     97}}}
     98
     99specifies the string "NONE".
     100
     101It is currently not possible to escape quotation marks in order to enclose them in strings - thus strings must not contain quotation marks.
     102
     103For 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
    44105== Extending filters at the back-end ==
     106