Skip to content

Commit 107fe18

Browse files
committed
added docs for as_alias
1 parent d221e8c commit 107fe18

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/src/piccolo/query_types/select.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ Or making an alias to make it shorter:
3131
3232
.. hint:: All of these examples also work with async by using .run() inside coroutines - see :ref:`SyncAndAsync`.
3333

34+
as_alias
35+
--------
36+
37+
By using ``as_alias``, the name of the row can be overriden in the response.
38+
39+
.. code-block:: python
40+
41+
>>> Band.select(Band.name.as_alias('title')).run_sync()
42+
[{'title': 'Rustaceans'}, {'title': 'Pythonistas'}]
43+
44+
This is equivalent to ``SELECT name AS title FROM band`` in SQL.
45+
3446
Joins
3547
-----
3648

0 commit comments

Comments
 (0)