From 8a24da6c10e31b885708215b66c561e3302b0e63 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 15 Dec 2015 18:30:54 -0500 Subject: [PATCH] - hyperlink default-related parameters (cherry picked from commit 9f6f34bc8f04e30115e047d78b9db96995bdb898) --- doc/build/core/defaults.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/build/core/defaults.rst b/doc/build/core/defaults.rst index e0e5666540..a7287a3608 100644 --- a/doc/build/core/defaults.rst +++ b/doc/build/core/defaults.rst @@ -45,7 +45,7 @@ defaults):: Python-Executed Functions ------------------------- -The ``default`` and ``onupdate`` keyword arguments also accept Python +The :paramref:`.Column.default` and :paramref:`.Column.onupdate` keyword arguments also accept Python functions. These functions are invoked at the time of insert or update if no other value for that column is supplied, and the value returned is used for the column's value. Below illustrates a crude "sequence" that assigns an @@ -67,12 +67,12 @@ built-in capabilities of the database should normally be used, which may include sequence objects or other autoincrementing capabilities. For primary key columns, SQLAlchemy will in most cases use these capabilities automatically. See the API documentation for -:class:`~sqlalchemy.schema.Column` including the ``autoincrement`` flag, as +:class:`~sqlalchemy.schema.Column` including the :paramref:`.Column.autoincrement` flag, as well as the section on :class:`~sqlalchemy.schema.Sequence` later in this chapter for background on standard primary key generation techniques. To illustrate onupdate, we assign the Python ``datetime`` function ``now`` to -the ``onupdate`` attribute:: +the :paramref:`.Column.onupdate` attribute:: import datetime @@ -93,7 +93,7 @@ executes. Context-Sensitive Default Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The Python functions used by ``default`` and ``onupdate`` may also make use of +The Python functions used by :paramref:`.Column.default` and :paramref:`.Column.onupdate` may also make use of the current statement's context in order to determine a value. The `context` of a statement is an internal SQLAlchemy object which contains all information about the statement being executed, including its source expression, the @@ -185,12 +185,12 @@ performance reasons. When the statement is executed with a single set of parameters (that is, it is not an "executemany" style execution), the returned :class:`~sqlalchemy.engine.ResultProxy` will contain a collection -accessible via ``result.postfetch_cols()`` which contains a list of all +accessible via :meth:`.ResultProxy.postfetch_cols` which contains a list of all :class:`~sqlalchemy.schema.Column` objects which had an inline-executed default. Similarly, all parameters which were bound to the statement, including all Python and SQL expressions which were pre-executed, are present -in the ``last_inserted_params()`` or ``last_updated_params()`` collections on -:class:`~sqlalchemy.engine.ResultProxy`. The ``inserted_primary_key`` +in the :meth:`.ResultProxy.last_inserted_params` or :meth:`.ResultProxy.last_updated_params` collections on +:class:`~sqlalchemy.engine.ResultProxy`. The :attr:`.ResultProxy.inserted_primary_key` collection contains a list of primary key values for the row inserted (a list so that single-column and composite-column primary keys are represented in the same format). @@ -200,8 +200,8 @@ same format). Server Side Defaults -------------------- -A variant on the SQL expression default is the ``server_default``, which gets -placed in the CREATE TABLE statement during a ``create()`` operation: +A variant on the SQL expression default is the :paramref:`.Column.server_default`, which gets +placed in the CREATE TABLE statement during a :meth:`.Table.create` operation: .. sourcecode:: python+sql @@ -217,7 +217,7 @@ A create call for the above table will produce:: created_at datetime default sysdate ) -The behavior of ``server_default`` is similar to that of a regular SQL +The behavior of :paramref:`.Column.server_default` is similar to that of a regular SQL default; if it's placed on a primary key column for a database which doesn't have a way to "postfetch" the ID, and the statement is not "inlined", the SQL expression is pre-executed; otherwise, SQLAlchemy lets the default fire off on -- 2.47.2