summaryrefslogtreecommitdiff
path: root/doc/build/core/sqlelement.rst
blob: 23dd2118b009ec9f59f0e875e8a6fa14fcec6fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
Column Elements and Expressions
===============================

.. currentmodule:: sqlalchemy.sql.expression

The expression API consists of a series of classes each of which represents a
specific lexical element within a SQL string.  Composed together
into a larger structure, they form a statement construct that may
be *compiled* into a string representation that can be passed to a database.
The classes are organized into a hierarchy that begins at the basemost
:class:`.ClauseElement` class. Key subclasses include :class:`.ColumnElement`,
which represents the role of any column-based expression
in a SQL statement, such as in the columns clause, WHERE clause, and ORDER BY
clause, and :class:`.FromClause`, which represents the role of a token that
is placed in the FROM clause of a SELECT statement.

.. _sqlelement_foundational_constructors:

Column Element Foundational Constructors
-----------------------------------------

Standalone functions imported from the ``sqlalchemy`` namespace which are
used when building up SQLAlchemy Expression Language constructs.

.. autofunction:: and_

.. autofunction:: bindparam

.. autofunction:: bitwise_not

.. autofunction:: case

.. autofunction:: cast

.. autofunction:: column

.. autoclass:: custom_op
   :members:

.. autofunction:: distinct

.. autofunction:: extract

.. autofunction:: false

.. autodata:: func

.. autofunction:: lambda_stmt

.. autofunction:: literal

.. autofunction:: literal_column

.. autofunction:: not_

.. autofunction:: null

.. autofunction:: or_

.. autofunction:: outparam

.. autofunction:: text

.. autofunction:: true

.. autofunction:: tuple_

.. autofunction:: type_coerce

.. autoclass:: quoted_name

   .. attribute:: quote

      whether the string should be unconditionally quoted


.. _sqlelement_modifier_constructors:

Column Element Modifier Constructors
-------------------------------------

Functions listed here are more commonly available as methods from any
:class:`_sql.ColumnElement` construct, for example, the
:func:`_sql.label` function is usually invoked via the
:meth:`_sql.ColumnElement.label` method.

.. autofunction:: all_

.. autofunction:: any_

.. autofunction:: asc

.. autofunction:: between

.. autofunction:: collate

.. autofunction:: desc

.. autofunction:: funcfilter

.. autofunction:: label

.. autofunction:: nulls_first

.. function:: nullsfirst

   Synonym for the :func:`_sql.nulls_first` function.

   .. versionchanged:: 2.0.5 restored missing legacy symbol :func:`.nullsfirst`.

.. autofunction:: nulls_last

.. function:: nullslast

   Legacy synonym for the :func:`_sql.nulls_last` function.

   .. versionchanged:: 2.0.5 restored missing legacy symbol :func:`.nullslast`.

.. autofunction:: over

.. autofunction:: within_group

Column Element Class Documentation
-----------------------------------

The classes here are generated using the constructors listed at
:ref:`sqlelement_foundational_constructors` and
:ref:`sqlelement_modifier_constructors`.


.. autoclass:: BinaryExpression
   :members:

.. autoclass:: BindParameter
   :members:

.. autoclass:: Case
   :members:

.. autoclass:: Cast
   :members:

.. autoclass:: ClauseList
   :members:


.. autoclass:: ColumnClause
   :members:

.. autoclass:: ColumnCollection
   :members:

.. autoclass:: ColumnElement
   :members:
   :inherited-members:
   :undoc-members:

.. data:: ColumnExpressionArgument

   General purpose "column expression" argument.

   .. versionadded:: 2.0.13

   This type is used for "column" kinds of expressions that typically represent
   a single SQL column expression, including :class:`_sql.ColumnElement`, as
   well as ORM-mapped attributes that will have a ``__clause_element__()``
   method.


.. autoclass:: ColumnOperators
   :members:
   :special-members:
   :inherited-members:


.. autoclass:: Extract
   :members:

.. autoclass:: False_
   :members:

.. autoclass:: FunctionFilter
   :members:

.. autoclass:: Label
   :members:

.. autoclass:: Null
   :members:

.. autoclass:: Operators
   :members:
   :special-members:

.. autoclass:: Over
   :members:

.. autoclass:: SQLColumnExpression

.. autoclass:: TextClause
   :members:

.. autoclass:: Tuple
   :members:

.. autoclass:: WithinGroup
   :members:

.. autoclass:: sqlalchemy.sql.elements.WrapsColumnExpression
   :members:

.. autoclass:: True_
   :members:

.. autoclass:: TypeCoerce
   :members:

.. autoclass:: UnaryExpression
   :members: