doc/book/en/annexes/rql/language.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 07 Jul 2011 18:20:23 +0200
changeset 7632 3c9dfc6e820b
parent 7578 49be8619b745
child 7738 e0c86caf5c48
permissions -rw-r--r--
[book] fix some rest/sphinx errors
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
.. _RQL:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     4
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
RQL syntax
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     6
----------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
     8
.. _RQLKeywords:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
     9
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    10
Reserved keywords
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    11
~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    12
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    13
::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    14
3686
d44b17016944 [doc] document rql operator ILIKE
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    15
  AND, ASC, BEING, DELETE, DESC, DISTINCT, EXISTS, FALSE, GROUPBY,
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    16
  HAVING, ILIKE, INSERT, LIKE, LIMIT, NOT, NOW, NULL, OFFSET,
3686
d44b17016944 [doc] document rql operator ILIKE
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
    17
  OR, ORDERBY, SET, TODAY, TRUE, UNION, WHERE, WITH
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    18
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    19
The keywords are not case sensitive. You should not use them when defining your
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    20
schema, or as RQL variable names.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
    21
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    22
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    23
.. _RQLCase:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
    24
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    25
Case
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    26
~~~~
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    27
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    28
* Variables should be all upper-cased.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    29
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    30
* Relation should be all lower-cased and match exactly names of relations defined
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    31
  in the schema.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    32
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    33
* Entity types should start with an upper cased letter and be followed by at least
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    34
  a lower cased latter.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    35
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    36
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    37
.. _RQLVariables:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
    38
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    39
Variables and typing
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    40
~~~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    41
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    42
Entities and values to browse and/or select are represented in the query by
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    43
*variables* that must be written in capital letters.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
    44
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    45
With RQL, we do not distinguish between entities and attributes. The value of an
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    46
attribute is considered as an entity of a particular type (see below), linked to
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    47
one (real) entity by a relation called the name of the attribute, where the
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    48
entity is the subject and the attribute the object.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    49
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    50
The possible type(s) for each variable is derived from the schema according to
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    51
the constraints expressed above and thanks to the relations between each
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    52
variable.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    53
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    54
We can restrict the possible types for a variable using the special relation
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    55
**is** in the restrictions.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    56
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    57
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    58
Virtual relations
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    59
~~~~~~~~~~~~~~~~~
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    60
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    61
Those relations may only be used in RQL query but are not actual attributes of
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    62
your entities.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    63
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    64
* `has_text`: relation to use to query the full text index (only for entities
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    65
  having fulltextindexed attributes).
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    66
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    67
* `identity`: relation to use to tell that a RQL variable is the same as another
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    68
  when you've to use two different variables for querying purpose. On the
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
    69
  opposite it's also useful together with the :ref:`NOT` operator to tell that two
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    70
  variables should not identify the same entity
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    71
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    72
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    73
.. _RQLLiterals:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
    74
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    75
Literal expressions
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    76
~~~~~~~~~~~~~~~~~~~
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    77
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    78
Bases types supported by RQL are those supported by yams schema. Literal values
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    79
are expressed as explained below:
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    80
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    81
* string should be between double or single quotes. If the value contains a
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    82
  quote, it should be preceded by a backslash '\'
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    83
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    84
* floats separator is dot '.'
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    85
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    86
* boolean values are :keyword:`TRUE` and :keyword:`FALSE` keywords
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    87
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    88
* date and time should be expressed as a string with ISO notation : YYYY/MM/DD
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    89
  [hh:mm], or using keywords :keyword:`TODAY` and :keyword:`NOW`
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    90
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    91
You may also use the :keyword:`NULL` keyword, meaning 'unspecified'.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    92
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    93
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    94
.. _RQLOperators:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
    95
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    96
Operators
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    97
~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    98
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
    99
.. _RQLLogicalOperators:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   100
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   101
Logical operators
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   102
`````````````````
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   103
::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   104
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   105
     AND, OR, NOT, ','
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   106
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   107
',' is equivalent to 'AND' but with the smallest among the priority of logical
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   108
operators (see :ref:`RQLOperatorsPriority`).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   109
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   110
.. _RQLMathematicalOperators:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   111
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   112
Mathematical operators
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   113
``````````````````````
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   114
::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   115
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   116
     +, -, *, /
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   117
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   118
Those should behave as you expect.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   119
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   120
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   121
.. _RQLComparisonOperators:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   122
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   123
Comparison operators
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   124
````````````````````
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   125
 ::
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   126
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   127
     =, !=, <, <=, >=, >, IN
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   128
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   129
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   130
The syntax to use comparison operators is:
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   131
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   132
    `VARIABLE attribute <operator> VALUE`
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   133
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   134
The `=` operator is the default operator and can be omitted, i.e. :
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   135
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   136
    `VARIABLE attribute = VALUE`
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   137
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   138
is equivalent to
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   139
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   140
    `VARIABLE attribute VALUE`
3686
d44b17016944 [doc] document rql operator ILIKE
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2175
diff changeset
   141
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   142
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   143
The operator `IN` provides a list of possible values: ::
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   144
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   145
    Any X WHERE X name IN ('chauvat', 'fayolle', 'di mascio', 'thenault')
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   146
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   147
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   148
.. _RQLStringOperators:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   149
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   150
String operators
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   151
````````````````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   152
::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   153
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   154
  LIKE, ILIKE, ~=, REGEXP
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   155
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   156
The :keyword:`LIKE` string operator can be used with the special character `%` in
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   157
a string as wild-card: ::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   158
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   159
     # match every entity whose name starts with 'Th'
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   160
     Any X WHERE X name ~= 'Th%'
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   161
     # match every entity whose name endswith 'lt'
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   162
     Any X WHERE X name LIKE '%lt'
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   163
     # match every entity whose name contains a 'l' and a 't'
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   164
     Any X WHERE X name LIKE '%l%t%'
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   165
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   166
:keyword:`ILIKE` is the case insensitive version of :keyword:`LIKE`. It's not
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   167
available on all backend (e.g. sqlite doesn't support it). If not available for
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   168
your backend, :keyword:`ILIKE` will behave like :keyword:`LIKE`.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   169
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   170
`~=` is a shortcut version of :keyword:`ILIKE`, or of :keyword:`LIKE` when the
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   171
former is not available on the back-end.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   172
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   173
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   174
The :keyword:`REGEXP` is an alternative to :keyword:`LIKE` that supports POSIX
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   175
regular expressions::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   176
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   177
   # match entities whose title starts with a digit
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   178
   Any X WHERE X title REGEXP "^[0-9].*"
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   179
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   180
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   181
The underlying SQL operator used is back-end-dependent :
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   182
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   183
- the ``~`` operator is used for postgresql,
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   184
- the ``REGEXP`` operator for mysql and sqlite.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   185
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   186
Other back-ends are not supported yet.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   187
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   188
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   189
.. _RQLOperatorsPriority:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   190
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   191
Operators priority
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   192
``````````````````
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   193
6324
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6120
diff changeset
   194
#. "(", ")"
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6120
diff changeset
   195
#. '*', '/'
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6120
diff changeset
   196
#. '+', '-'
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6120
diff changeset
   197
#. 'NOT'
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6120
diff changeset
   198
#. 'AND'
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6120
diff changeset
   199
#. 'OR'
bdb85e3602c8 [book] minor update about windmill + reformat
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6120
diff changeset
   200
#. ','
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   201
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   202
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   203
.. _RQLSearchQuery:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   204
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   205
Search Query
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   206
~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   207
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   208
Simplified grammar of search query: ::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   209
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   210
   [ `DISTINCT`] `Any` V1 (, V2) \*
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   211
   [ `GROUPBY` V1 (, V2) \*] [ `ORDERBY` <orderterms>]
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   212
   [ `LIMIT` <value>] [ `OFFSET` <value>]
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   213
   [ `WHERE` <triplet restrictions>]
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   214
   [ `WITH` V1 (, V2)\* BEING (<query>)]
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   215
   [ `HAVING` <other restrictions>]
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   216
   [ `UNION` <query>]
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   217
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   218
Selection
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   219
`````````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   220
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   221
The fist occuring clause is the selection of terms that should be in the result
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   222
set.  Terms may be variable, literals, function calls, arithmetic, etc. and each
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   223
term is separated by a comma.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   224
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   225
There will be as much column in the result set as term in this clause, respecting
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   226
order.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   227
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   228
Syntax for function call is somewhat intuitive, for instance: ::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   229
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   230
    Any UPPER(N) WHERE P firstname N
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   231
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   232
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   233
Grouping and aggregating
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   234
````````````````````````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   235
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   236
The :keyword:`GROUPBY` keyword is followed by a list of terms on which results
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   237
should be grouped. They are usually used with aggregate functions, responsible to
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   238
aggregate values for each group (see :ref:`RQLAggregateFunctions`).
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   239
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   240
For grouped queries, all selected variables must be either aggregated (i.e. used
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   241
by an aggregate function) or grouped (i.e. listed in the :keyword:`GROUPBY`
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   242
clause).
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   243
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   244
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   245
Sorting
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   246
```````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   247
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   248
The :keyword:`ORDERBY` keyword if followed by the definition of the selection
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   249
order: variable or column number followed by sorting method (:keyword:`ASC`,
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   250
:keyword:`DESC`), :keyword:`ASC` being the default. If the sorting method is not
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   251
specified, then the sorting is ascendant (`ASC`).
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   252
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   253
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   254
Pagination
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   255
``````````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   256
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   257
The :keyword:`LIMIT` and :keyword:`OFFSET` keywords may be respectively used to
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   258
limit the number of results and to tell from which result line to start (for
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   259
instance, use `LIMIT 20` to get the first 20 results, then `LIMIT 20 OFFSET 20`
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   260
to get the next 20.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   261
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   262
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   263
Restrictions
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   264
````````````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   265
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   266
The :keyword:`WHERE` keyword introduce one of the "main" part of the query, where
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   267
you "define" variables and add some restrictions telling what you're interested
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   268
in.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   269
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   270
It's a list of triplets "subject relation object", e.g. `V1 relation
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   271
(V2 | <static value>)`. Triplets are separated using :ref:`RQLLogicalOperators`.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   272
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   273
.. Note:
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   274
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   275
  About the negation operator (:keyword:`NOT`):
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   276
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   277
  * "NOT X relation Y" is equivalent to "NOT EXISTS(X relation Y)"
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   278
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   279
  * `Any X WHERE NOT X owned_by U` means "entities that have no relation
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   280
    `owned_by`".
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   281
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   282
  * `Any X WHERE NOT X owned_by U, U login "syt"` means "the entity have no
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   283
     relation `owned_by` with the user syt". They may have a relation "owned_by"
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   284
     with another user.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   285
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   286
In this clause, you can also use :keyword:`EXISTS` when you want to know if some
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   287
expression is true and do not need the complete set of elements that make it
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   288
true. Testing for existence is much faster than fetching the complete set of
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   289
results, especially when you think about using `OR` against several expressions. For instance
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   290
if you want to retrieve versions which are in state "ready" or tagged by
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   291
"priority", you should write :
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   292
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   293
::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   294
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   295
    Any X ORDERBY PN,N
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   296
    WHERE X num N, X version_of P, P name PN,
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   297
          EXISTS(X in_state S, S name "ready")
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   298
          OR EXISTS(T tags X, T name "priority")
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   299
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   300
not
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   301
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   302
::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   303
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   304
    Any X ORDERBY PN,N
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   305
    WHERE X num N, X version_of P, P name PN,
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   306
          (X in_state S, S name "ready")
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   307
          OR (T tags X, T name "priority")
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   308
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   309
Both queries aren't at all equivalent :
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   310
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   311
* the former will retrieve all versions, then check for each one which are in the
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   312
  matching state of or tagged by the expected tag,
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   313
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   314
* the later will retrieve all versions, state and tags (cartesian product!),
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   315
  compute join and then exclude each row which are in the matching state of or
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   316
  tagged by the expected tag. This implies that : you won't get any result if the
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   317
  in_state or tag
7529
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7081
diff changeset
   318
2fdc310be7cd [book] add autoload section from code and fix sphinx warnings
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 7081
diff changeset
   319
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   320
You can also use the question mark (`?`) to mark optional relations which allow
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   321
you to select entities related **or not** to another. It is a similar concept
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   322
that the `Left outer join`_:
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   323
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   324
    the result of a left outer join (or simply left join) for table A and B
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   325
    always contains all records of the "left" table (A), even if the
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   326
    join-condition does not find any matching record in the "right" table (B).
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   327
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   328
You must use the `?` behind a variable to specify that the relation toward it
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   329
is optional. For instance:
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   330
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   331
- Anomalies of a project attached or not to a version ::
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   332
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   333
       Any X, V WHERE X concerns P, P eid 42, X corrected_in V?
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   334
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   335
  You will get a result set containing all the project's tickets, with either the
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   336
  version in which it's corrected or None for tickets not related to a version.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   337
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   338
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   339
- All cards and the project they document if any ::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   340
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   341
       Any C, P WHERE C is Card, P? documented_by C
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   342
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   343
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   344
Having restrictions
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   345
```````````````````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   346
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   347
The :keyword:`HAVING` clause, as in SQL, may be used to restrict a query
6120
c000e41316ec [book] some more documentation and cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5924
diff changeset
   348
according to value returned by an aggregate function, e.g.::
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   349
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   350
    Any X GROUPBY X WHERE X relation Y HAVING COUNT(Y) > 10
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   351
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   352
It may however be used for something else: In the :keyword:`WHERE` clause, we are
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   353
limited to triplet expressions, so some things may not be expressed there. Let's
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   354
take an example : if you want to get people whose upper-cased first name equals to
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   355
another person upper-cased first name. There is no proper way to express this
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   356
using triplet, so you should use something like: ::
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   357
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   358
    Any X WHERE X firstname XFN, Y firstname YFN, NOT X identity Y HAVING UPPER(XFN) = UPPER(YFN)
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   359
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   360
Another example: imagine you want person born in 2000: ::
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   361
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   362
    Any X WHERE X birthday XB HAVING YEAR(XB) = 2000
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   363
6120
c000e41316ec [book] some more documentation and cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5924
diff changeset
   364
Notice that while we would like this to work without the HAVING clause, this
c000e41316ec [book] some more documentation and cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5924
diff changeset
   365
can't be currently be done because it introduces an ambiguity in RQL's grammar
c000e41316ec [book] some more documentation and cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5924
diff changeset
   366
that can't be handled by Yapps_, the parser's generator we're using.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   367
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   368
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   369
Sub-queries
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   370
```````````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   371
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   372
The :keyword:`WITH` keyword introduce sub-queries clause. Each sub-query has the
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   373
form:
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   374
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   375
  V1(,V2) BEING (rql query)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   376
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   377
Variables at the left of the :keyword:`BEING` keyword defines into which
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   378
variables results from the sub-query will be mapped to into the outer query.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   379
Sub-queries are separated from each other using a comma.
6120
c000e41316ec [book] some more documentation and cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5924
diff changeset
   380
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   381
Let's say we want to retrieve for each project its number of versions and its
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   382
number of tickets. Due to the nature of relational algebra behind the scene, this
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   383
can't be achieved using a single query. You have to write something along the
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   384
line of: ::
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   385
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   386
  Any X, VC, TC WHERE X identity XX
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   387
  WITH X, VC BEING (Any X, COUNT(V) GROUPBY X WHERE V version_of X),
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   388
       XX, TC BEING (Any X, COUNT(T) GROUPBY X WHERE T ticket_of X)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   389
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   390
Notice that we can't reuse a same variable name as alias for two different
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   391
sub-queries, hence the usage of 'X' and 'XX' in this example, which are then
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   392
unified using the special `identity` relation (see :ref:`XXX`).
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   393
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   394
.. Warning:
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   395
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   396
  Sub-queries define a new variable scope, so even if a variable has the same name
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   397
  in the outer query and in the sub-query, they technically **aren't* the same
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   398
  variable. So ::
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   399
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   400
     Any W, REF WITH W, REF BEING
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   401
         (Any W, REF WHERE W is Workcase, W ref REF,
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   402
                           W concerned_by D, D name "Logilab")
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   403
  could be written:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   404
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   405
     Any W, REF WITH W, REF BEING
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   406
        (Any W1, REF1 WHERE W1 is Workcase, W1 ref REF1,
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   407
                            W1 concerned_by D, D name "Logilab")
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   408
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   409
  Also, when a variable is coming from a sub-query, you currently can't reference
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   410
  its attribute or inlined relations in the outer query, you've to fetch them in
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   411
  the sub-query. For instance, let's say we want to sort by project name in our
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   412
  first example, we would have to write ::
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   413
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   414
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   415
    Any X, VC, TC ORDERBY XN WHERE X identity XX
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   416
    WITH X, XN, VC BEING (Any X, COUNT(V) GROUPBY X,XN WHERE V version_of X, X name XN),
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   417
         XX, TC BEING (Any X, COUNT(T) GROUPBY X WHERE T ticket_of X)
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   418
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   419
  instead of ::
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   420
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   421
    Any X, VC, TC ORDERBY XN WHERE X identity XX, X name XN,
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   422
    WITH X, XN, VC BEING (Any X, COUNT(V) GROUPBY X WHERE V version_of X),
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   423
         XX, TC BEING (Any X, COUNT(T) GROUPBY X WHERE T ticket_of X)
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   424
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   425
  which would result in a SQL execution error.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   426
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   427
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   428
Union
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   429
`````
7081
6beb7f1e05fa [doc] complete description of EXISTS in rql/language.rst
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6324
diff changeset
   430
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   431
You may get a result set containing the concatenation of several queries using
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   432
the :keyword:`UNION`. The selection of each query should have the same number of
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   433
columns.
7081
6beb7f1e05fa [doc] complete description of EXISTS in rql/language.rst
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6324
diff changeset
   434
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   435
::
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   436
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   437
    (Any X, XN WHERE X is Person, X surname XN) UNION (Any X,XN WHERE X is Company, X name XN)
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   438
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   439
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   440
.. _RQLFunctions:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   441
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   442
Available functions
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   443
~~~~~~~~~~~~~~~~~~~
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   444
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   445
Below is the list of aggregate and transformation functions that are supported
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   446
nativly by the framework. Notice that cubes may define additional functions.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   447
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   448
.. _RQLAggregateFunctions:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   449
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   450
Aggregate functions
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   451
```````````````````
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   452
+--------------------+----------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   453
| :func:`COUNT`      | return the number of rows                                |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   454
+--------------------+----------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   455
| :func:`MIN`        | return the minimum value                                 |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   456
+--------------------+----------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   457
| :func:`MAX`        | return the maximum value                                 |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   458
+--------------------+----------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   459
| :func:`AVG`        | return the average value                                 |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   460
+--------------------+----------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   461
| :func:`SUM`        | return the sum of values                                 |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   462
+--------------------+----------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   463
| :func:`COMMA_JOIN` | return each value separated by a comma (for string only) |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   464
+--------------------+----------------------------------------------------------+
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   465
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   466
All aggregate functions above take a single argument. Take care some aggregate
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   467
functions (e.g. :keyword:`MAX`, :keyword:`MIN`) may return `None` if there is no
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   468
result row.
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   469
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   470
.. _RQLStringFunctions:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   471
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   472
String transformation functions
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   473
```````````````````````````````
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   474
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   475
+-------------------------+-----------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   476
| :func:`UPPER(String)`   | upper case the string                                           |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   477
+-------------------------+-----------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   478
| :func:`LOWER(String)`   | lower case the string                                           |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   479
+-------------------------+-----------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   480
| :func:`LENGTH(String)`  | return the length of the string                                 |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   481
+-------------------------+-----------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   482
| :func:`SUBSTRING(       | extract from the string a string starting at given index and of |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   483
|  String, start, length)`| given length                                                    |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   484
+-------------------------+-----------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   485
| :func:`LIMIT_SIZE(      | if the length of the string is greater than given max size,     |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   486
|  String, max size)`     | strip it and add ellipsis ("..."). The resulting string will    |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   487
|                         | hence have max size + 3 characters                              |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   488
+-------------------------+-----------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   489
| :func:`TEXT_LIMIT_SIZE( | similar to the above, but allow to specify the MIME type of the |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   490
|  String, format,        | text contained by the string. Supported formats are text/html,  |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   491
|  max size)`             | text/xhtml and text/xml. All others will be considered as plain |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   492
|                         | text. For non plain text format, sgml tags will be first removed|
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   493
|                         | before limiting the string.                                     |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   494
+-------------------------+-----------------------------------------------------------------+
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   495
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   496
.. _RQLDateFunctions:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   497
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   498
Date extraction functions
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   499
`````````````````````````
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   500
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   501
+--------------------------+----------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   502
| :func:`YEAR(Date)`       | return the year of a date or datetime  |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   503
+--------------------------+----------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   504
| :func:`MONTH(Date)`      | return the year of a date or datetime  |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   505
+--------------------------+----------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   506
| :func:`DAY(Date)`        | return the year of a date or datetime  |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   507
+--------------------------+----------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   508
| :func:`HOUR(Datetime)`   | return the year of a datetime          |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   509
+--------------------------+----------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   510
| :func:`MINUTE(Datetime)` | return the year of a datetime          |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   511
+--------------------------+----------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   512
| :func:`SECOND(Datetime)` | return the year of a datetime          |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   513
+--------------------------+----------------------------------------+
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   514
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   515
.. _RQLOtherFunctions:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   516
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   517
Other functions
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   518
```````````````
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   519
+-----------------------+--------------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   520
| :func:`ABS(num)`      |  return the absolute value of a number                             |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   521
+-----------------------+--------------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   522
| :func:`RANDOM()`      | return a pseudo-random value from 0.0 to 1.0                       |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   523
+-----------------------+--------------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   524
| :func:`FSPATH(X)`     | expect X to be an attribute whose value is stored in a             |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   525
|                       | :class:`BFSStorage` and return its path on the file system         |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   526
+-----------------------+--------------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   527
| :func:`FTKIRANK(X)`   | expect X to be an entity used in a has_text relation, and return a |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   528
|                       | number corresponding to the rank order of each resulting entity    |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   529
+-----------------------+--------------------------------------------------------------------+
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   530
| :func:`CAST(Type, X)` | expect X to be an attribute and return it casted into the given    |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   531
|                       | final type                                                         |
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   532
+-----------------------+--------------------------------------------------------------------+
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   533
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   534
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   535
.. _RQLExamples:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   536
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   537
Examples
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   538
~~~~~~~~
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   539
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   540
- *Search for the object of identifier 53*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   541
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   542
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   543
        Any WHERE X
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   544
        X eid 53
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   545
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   546
- *Search material such as comics, owned by syt and available*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   547
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   548
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   549
        Any X WHERE X is Document
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   550
        X occurence_of F, F class C, C name 'Comics'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   551
        X owned_by U, U login 'syt'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   552
        X available TRUE
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   553
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   554
- *Looking for people working for eurocopter interested in training*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   555
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   556
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   557
        Any P WHERE
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   558
        P is Person, P work_for S, S name 'Eurocopter'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   559
        P interested_by T, T name 'training'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   560
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   561
- *Search note less than 10 days old written by jphc or ocy*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   562
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   563
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   564
        Any N WHERE
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   565
        N is Note, N written_on D, D day> (today -10),
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   566
        N written_by P, P name 'jphc' or P name 'ocy'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   567
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   568
- *Looking for people interested in training or living in Paris*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   569
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   570
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   571
        Any P WHERE
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   572
        P is Person, (P interested_by T, T name 'training') OR
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   573
        (P city 'Paris')
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   574
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   575
- *The surname and firstname of all people*
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   576
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   577
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   578
        Any N, P WHERE
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   579
        X is Person, X name N, X firstname P
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   580
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   581
  Note that the selection of several entities generally force
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   582
  the use of "Any" because the type specification applies otherwise
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   583
  to all the selected variables. We could write here
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   584
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   585
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   586
        String N, P WHERE
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   587
        X is Person, X name N, X first_name P
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   588
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   589
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   590
  Note: You can not specify several types with * ... where X is FirstType or X is SecondType*.
2043
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1714
diff changeset
   591
  To specify several types explicitly, you have to do
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   592
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   593
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   594
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   595
        Any X where X is in (FirstType, SecondType)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   596
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   597
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   598
.. _RQLInsertQuery:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   599
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   600
Insertion query
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   601
~~~~~~~~~~~~~~~
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   602
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   603
    `INSERT` <entity type> V1 (, <entity type> V2) \ * `:` <assignments>
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   604
    [ `WHERE` <restriction>]
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   605
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   606
:assignments:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   607
   list of relations to assign in the form `V1 relationship V2 | <static value>`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   608
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   609
The restriction can define variables used in assignments.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   610
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   611
Caution, if a restriction is specified, the insertion is done for
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   612
*each line result returned by the restriction*.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   613
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   614
- *Insert a new person named 'foo'*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   615
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   616
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   617
        INSERT Person X: X name 'foo'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   618
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   619
- *Insert a new person named 'foo', another called 'nice' and a 'friend' relation
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   620
  between them*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   621
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   622
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   623
        INSERT Person X, Person Y: X name 'foo', Y name 'nice', X friend Y
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   624
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   625
- *Insert a new person named 'foo' and a 'friend' relation with an existing
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   626
  person called 'nice'*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   627
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   628
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   629
        INSERT Person X: X name 'foo', X friend  Y WHERE name 'nice'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   630
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   631
.. _RQLSetQuery:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   632
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   633
Update and relation creation queries
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   634
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   635
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   636
    `SET` <assignements>
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   637
    [ `WHERE` <restriction>]
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   638
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   639
Caution, if a restriction is specified, the update is done *for
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   640
each result line returned by the restriction*.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   641
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   642
- *Renaming of the person named 'foo' to 'bar' with the first name changed*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   643
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   644
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   645
        SET X name 'bar', X firstname 'original' WHERE X is Person, X name 'foo'
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   646
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2043
diff changeset
   647
- *Insert a relation of type 'know' between objects linked by
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   648
  the relation of type 'friend'*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   649
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   650
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   651
        SET X know Y  WHERE X friend Y
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   652
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   653
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   654
.. _RQLDeleteQuery:
7632
3c9dfc6e820b [book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7578
diff changeset
   655
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   656
Deletion query
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   657
~~~~~~~~~~~~~~
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   658
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   659
    `DELETE` (<entity type> V) | (V1 relation v2 ),...
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   660
    [ `WHERE` <restriction>]
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   661
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   662
Caution, if a restriction is specified, the deletion is made *for
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   663
each line result returned by the restriction*.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   664
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   665
- *Deletion of the person named 'foo'*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   666
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   667
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   668
        DELETE Person X WHERE X name 'foo'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   669
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   670
- *Removal of all relations of type 'friend' from the person named 'foo'*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   671
  ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   672
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   673
        DELETE X friend Y WHERE X is Person, X name 'foo'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   674
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   675
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   676
.. _Yapps: http://theory.stanford.edu/~amitp/yapps/
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5393
diff changeset
   677
.. _Left outer join: http://en.wikipedia.org/wiki/Join_(SQL)#Left_outer_join
7578
49be8619b745 [book] rewrite / complete the RQL language chapter
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7529
diff changeset
   678