Skip to content

Commit 48080d8

Browse files
committed
- add in all the method-chained methods to the parameter descriptions
on select(). improve some descriptions and add more info for limit()/ offset(), including new 1.0 functionality.
1 parent 7904ebc commit 48080d8

File tree

1 file changed

+131
-43
lines changed

1 file changed

+131
-43
lines changed

lib/sqlalchemy/sql/selectable.py

Lines changed: 131 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,14 +1742,42 @@ def _offset(self):
17421742
@_generative
17431743
def limit(self, limit):
17441744
"""return a new selectable with the given LIMIT criterion
1745-
applied."""
1745+
applied.
1746+
1747+
This is a numerical value which usually renders as a ``LIMIT``
1748+
expression in the resulting select. Backends that don't
1749+
support ``LIMIT`` will attempt to provide similar
1750+
functionality.
1751+
1752+
.. versionchanged:: 1.0.0 - :meth:`.Select.limit` can now
1753+
accept arbitrary SQL expressions as well as integer values.
1754+
1755+
:param limit: an integer LIMIT parameter, or a SQL expression
1756+
that provides an integer result.
1757+
1758+
"""
17461759

17471760
self._limit_clause = _offset_or_limit_clause(limit)
17481761

17491762
@_generative
17501763
def offset(self, offset):
17511764
"""return a new selectable with the given OFFSET criterion
1752-
applied."""
1765+
applied.
1766+
1767+
1768+
This is a numeric value which usually renders as an ``OFFSET``
1769+
expression in the resulting select. Backends that don't
1770+
support ``OFFSET`` will attempt to provide similar
1771+
functionality.
1772+
1773+
1774+
.. versionchanged:: 1.0.0 - :meth:`.Select.offset` can now
1775+
accept arbitrary SQL expressions as well as integer values.
1776+
1777+
:param offset: an integer OFFSET parameter, or a SQL expression
1778+
that provides an integer result.
1779+
1780+
"""
17531781

17541782
self._offset_clause = _offset_or_limit_clause(offset)
17551783

@@ -2156,38 +2184,57 @@ def __init__(self,
21562184
:func:`.select`.
21572185
21582186
:param columns:
2159-
A list of :class:`.ClauseElement` objects, typically
2160-
:class:`.ColumnElement` objects or subclasses, which will form the
2161-
columns clause of the resulting statement. For all members which are
2162-
instances of :class:`.Selectable`, the individual
2163-
:class:`.ColumnElement` members of the :class:`.Selectable` will be
2164-
added individually to the columns clause. For example, specifying a
2165-
:class:`~sqlalchemy.schema.Table` instance will result in all the
2166-
contained :class:`~sqlalchemy.schema.Column` objects within to be
2167-
added to the columns clause.
2168-
2169-
This argument is not present on the form of :func:`select()`
2170-
available on :class:`~sqlalchemy.schema.Table`.
2187+
A list of :class:`.ColumnElement` or :class:`.FromClause`
2188+
objects which will form the columns clause of the resulting
2189+
statement. For those objects that are instances of
2190+
:class:`.FromClause` (typically :class:`.Table` or :class:`.Alias`
2191+
objects), the :attr:`.FromClause.c` collection is extracted
2192+
to form a collection of :class:`.ColumnElement` objects.
2193+
2194+
This parameter will also accept :class:`.Text` constructs as
2195+
given, as well as ORM-mapped classes.
2196+
2197+
.. note::
2198+
2199+
The :paramref:`.select.columns` parameter is not available
2200+
in the method form of :func:`.select`, e.g.
2201+
:meth:`.FromClause.select`.
2202+
2203+
.. seealso::
2204+
2205+
:meth:`.Select.column`
2206+
2207+
:meth:`.Select.with_only_columns`
21712208
21722209
:param whereclause:
21732210
A :class:`.ClauseElement` expression which will be used to form the
2174-
``WHERE`` clause.
2211+
``WHERE`` clause. It is typically preferable to add WHERE
2212+
criterion to an existing :class:`.Select` using method chaining
2213+
with :meth:`.Select.where`.
2214+
2215+
.. seealso::
2216+
2217+
:meth:`.Select.where`
21752218
21762219
:param from_obj:
21772220
A list of :class:`.ClauseElement` objects which will be added to the
2178-
``FROM`` clause of the resulting statement. Note that "from" objects
2179-
are automatically located within the columns and whereclause
2180-
ClauseElements. Use this parameter to explicitly specify "from"
2181-
objects which are not automatically locatable. This could include
2182-
:class:`~sqlalchemy.schema.Table` objects that aren't otherwise
2183-
present, or :class:`.Join` objects whose presence will supersede
2184-
that of the :class:`~sqlalchemy.schema.Table` objects already
2185-
located in the other clauses.
2221+
``FROM`` clause of the resulting statement. This is equivalent
2222+
to calling :meth:`.Select.select_from` using method chaining on
2223+
an existing :class:`.Select` object.
2224+
2225+
.. seealso::
2226+
2227+
:meth:`.Select.select_from` - full description of explicit
2228+
FROM clause specification.
21862229
21872230
:param autocommit:
2188-
Deprecated. Use .execution_options(autocommit=<True|False>)
2231+
Deprecated. Use ``.execution_options(autocommit=<True|False>)``
21892232
to set the autocommit option.
21902233
2234+
.. seealso::
2235+
2236+
:meth:`.Executable.execution_options`
2237+
21912238
:param bind=None:
21922239
an :class:`~.Engine` or :class:`~.Connection` instance
21932240
to which the
@@ -2199,11 +2246,13 @@ def __init__(self,
21992246
:param correlate=True:
22002247
indicates that this :class:`.Select` object should have its
22012248
contained :class:`.FromClause` elements "correlated" to an enclosing
2202-
:class:`.Select` object. This means that any
2203-
:class:`.ClauseElement` instance within the "froms" collection of
2204-
this :class:`.Select` which is also present in the "froms"
2205-
collection of an enclosing select will not be rendered in the
2206-
``FROM`` clause of this select statement.
2249+
:class:`.Select` object. It is typically preferable to specify
2250+
correlations on an existing :class:`.Select` construct using
2251+
:meth:`.Select.correlate`.
2252+
2253+
.. seealso::
2254+
2255+
:meth:`.Select.correlate` - full description of correlation.
22072256
22082257
:param distinct=False:
22092258
when ``True``, applies a ``DISTINCT`` qualifier to the columns
@@ -2214,15 +2263,19 @@ def __init__(self,
22142263
is understood by the Postgresql dialect to render the
22152264
``DISTINCT ON (<columns>)`` syntax.
22162265
2217-
``distinct`` is also available via the :meth:`~.Select.distinct`
2218-
generative method.
2266+
``distinct`` is also available on an existing :class:`.Select`
2267+
object via the :meth:`~.Select.distinct` method.
2268+
2269+
.. seealso::
2270+
2271+
:meth:`.Select.distinct`
22192272
22202273
:param for_update=False:
22212274
when ``True``, applies ``FOR UPDATE`` to the end of the
22222275
resulting statement.
22232276
22242277
.. deprecated:: 0.9.0 - use
2225-
:meth:`.GenerativeSelect.with_for_update` to specify the
2278+
:meth:`.Select.with_for_update` to specify the
22262279
structure of the ``FOR UPDATE`` clause.
22272280
22282281
``for_update`` accepts various string values interpreted by
@@ -2237,32 +2290,62 @@ def __init__(self,
22372290
22382291
.. seealso::
22392292
2240-
:meth:`.GenerativeSelect.with_for_update` - improved API for
2293+
:meth:`.Select.with_for_update` - improved API for
22412294
specifying the ``FOR UPDATE`` clause.
22422295
22432296
:param group_by:
22442297
a list of :class:`.ClauseElement` objects which will comprise the
2245-
``GROUP BY`` clause of the resulting select.
2298+
``GROUP BY`` clause of the resulting select. This parameter
2299+
is typically specified more naturally using the
2300+
:meth:`.Select.group_by` method on an existing :class:`.Select`.
2301+
2302+
.. seealso::
2303+
2304+
:meth:`.Select.group_by`
22462305
22472306
:param having:
22482307
a :class:`.ClauseElement` that will comprise the ``HAVING`` clause
2249-
of the resulting select when ``GROUP BY`` is used.
2308+
of the resulting select when ``GROUP BY`` is used. This parameter
2309+
is typically specified more naturally using the
2310+
:meth:`.Select.having` method on an existing :class:`.Select`.
2311+
2312+
.. seealso::
2313+
2314+
:meth:`.Select.having`
22502315
22512316
:param limit=None:
2252-
a numerical value which usually compiles to a ``LIMIT``
2253-
expression in the resulting select. Databases that don't
2317+
a numerical value which usually renders as a ``LIMIT``
2318+
expression in the resulting select. Backends that don't
22542319
support ``LIMIT`` will attempt to provide similar
2255-
functionality.
2320+
functionality. This parameter is typically specified more naturally
2321+
using the :meth:`.Select.limit` method on an existing
2322+
:class:`.Select`.
2323+
2324+
.. seealso::
2325+
2326+
:meth:`.Select.limit`
22562327
22572328
:param offset=None:
2258-
a numeric value which usually compiles to an ``OFFSET``
2259-
expression in the resulting select. Databases that don't
2329+
a numeric value which usually renders as an ``OFFSET``
2330+
expression in the resulting select. Backends that don't
22602331
support ``OFFSET`` will attempt to provide similar
2261-
functionality.
2332+
functionality. This parameter is typically specified more naturally
2333+
using the :meth:`.Select.offset` method on an existing
2334+
:class:`.Select`.
2335+
2336+
.. seealso::
2337+
2338+
:meth:`.Select.offset`
22622339
22632340
:param order_by:
22642341
a scalar or list of :class:`.ClauseElement` objects which will
22652342
comprise the ``ORDER BY`` clause of the resulting select.
2343+
This parameter is typically specified more naturally using the
2344+
:meth:`.Select.order_by` method on an existing :class:`.Select`.
2345+
2346+
.. seealso::
2347+
2348+
:meth:`.Select.order_by`
22662349
22672350
:param use_labels=False:
22682351
when ``True``, the statement will be generated using labels
@@ -2273,8 +2356,13 @@ def __init__(self,
22732356
collection of the resulting :class:`.Select` object will use these
22742357
names as well for targeting column members.
22752358
2276-
use_labels is also available via the
2277-
:meth:`~.GenerativeSelect.apply_labels` generative method.
2359+
This parameter can also be specified on an existing
2360+
:class:`.Select` object using the :meth:`.Select.apply_labels`
2361+
method.
2362+
2363+
.. seealso::
2364+
2365+
:meth:`.Select.apply_labels`
22782366
22792367
"""
22802368
self._auto_correlate = correlate

0 commit comments

Comments
 (0)