From: Mike Bayer Date: Thu, 18 Feb 2016 16:33:19 +0000 (-0500) Subject: - further edit the unnest() example to suit PG's esoteric requirements X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=313c1261a6208c7fe1303649fb21b58f02b80042;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - further edit the unnest() example to suit PG's esoteric requirements exactly (cherry picked from commit c97aa63789036fc145503f03123275253ae02d2c) --- diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py index 327dafc426..230ac6cc29 100644 --- a/lib/sqlalchemy/sql/functions.py +++ b/lib/sqlalchemy/sql/functions.py @@ -133,14 +133,16 @@ class FunctionElement(Executable, ColumnElement, FromClause): :class:`.FunctionElement`. This construct wraps the function in a named alias which - is suitable for the FROM clause. + is suitable for the FROM clause, in the style accepted for example + by Postgresql. e.g.:: from sqlalchemy.sql import column - stmt = select([column('data_view')]).select_from( - func.unnest(Table.data).alias('data_view') + stmt = select([column('data_view')]).\\ + select_from(SomeTable).\\ + select_from(func.unnest(SomeTable.data).alias('data_view') ) Would produce: @@ -148,7 +150,7 @@ class FunctionElement(Executable, ColumnElement, FromClause): .. sourcecode:: sql SELECT data_view - FROM unnest(sometable.data) AS data_view + FROM sometable, unnest(sometable.data) AS data_view .. versionadded:: 0.9.8 The :meth:`.FunctionElement.alias` method is now supported. Previously, this method's behavior was