Skip to content

Commit

Permalink
[3.0.x] Doc'd return values of as_sql() for Func and query expressions.
Browse files Browse the repository at this point in the history
Backport of 8c1b073 from master
  • Loading branch information
adamchainz authored and felixxm committed Mar 6, 2020
1 parent f389e2c commit cc20699
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/ref/models/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ The ``Func`` API is as follows:

.. method:: as_sql(compiler, connection, function=None, template=None, arg_joiner=None, **extra_context)

Generates the SQL for the database function.
Generates the SQL fragment for the database function. Returns a tuple
``(sql, params)``, where ``sql`` is the SQL string, and ``params`` is
the list or tuple of query parameters.

The ``as_vendor()`` methods should use the ``function``, ``template``,
``arg_joiner``, and any other ``**extra_context`` parameters to
Expand Down
10 changes: 6 additions & 4 deletions docs/ref/models/lookups.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ following methods:

.. method:: as_sql(compiler, connection)

Responsible for producing the query string and parameters for the expression.
The ``compiler`` is an ``SQLCompiler`` object, which has a ``compile()``
method that can be used to compile other expressions. The ``connection`` is
the connection used to execute the query.
Generates the SQL fragment for the expression. Returns a tuple
``(sql, params)``, where ``sql`` is the SQL string, and ``params`` is the
list or tuple of query parameters. The ``compiler`` is an ``SQLCompiler``
object, which has a ``compile()`` method that can be used to compile other
expressions. The ``connection`` is the connection used to execute the
query.

Calling ``expression.as_sql()`` is usually incorrect - instead
``compiler.compile(expression)`` should be used. The ``compiler.compile()``
Expand Down

0 comments on commit cc20699

Please sign in to comment.