diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2020-06-11 03:14:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-06-11 03:14:46 +0000 |
commit | e1d4e59116bbf1a12bb6b3f57d33ddfc757d4567 (patch) | |
tree | b09db2bba8019b1d11720f1092304e5ce9948d91 | |
parent | 0c6f356f019499160993e71f7be9b21852cdcd4a (diff) | |
parent | 95106a9175741528cebfde8b6d0fd9756f82bd20 (diff) | |
download | sqlalchemy-e1d4e59116bbf1a12bb6b3f57d33ddfc757d4567.tar.gz |
Merge "Add documentation regarding row constructo in PostgreSQL"
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 24e2d13d8..924cd6908 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -566,7 +566,7 @@ PostgreSQL to ensure that you are generating queries with SQLAlchemy that take full advantage of any indexes you may have created for full text search. FROM ONLY ... ------------------------- +------------- The dialect supports PostgreSQL's ONLY keyword for targeting only a particular table in an inheritance hierarchy. This can be used to produce the @@ -813,6 +813,50 @@ dialect in conjunction with the :class:`_schema.Table` construct: `PostgreSQL CREATE TABLE options <http://www.postgresql.org/docs/current/static/sql-createtable.html>`_ +Table values, Row and Tuple objects +----------------------------------- + +Row Types +^^^^^^^^^ + +Built-in support for rendering a ``ROW`` is not available yet, however the +:func:`_expression.tuple_` may be used in its place. Another alternative is +to use the :attr:`_sa.func` generator with ``func.ROW`` :: + + table.select().where( + tuple_(table.c.id, table.c.fk) > (1,2) + ).where(func.ROW(table.c.id, table.c.fk) < func.ROW(3, 7)) + +Will generate the row-wise comparison:: + + SELECT * + FROM table + WHERE (id, fk) > (1, 2) + AND ROW(id, fk) < ROW(3, 7) + +.. seealso:: + + `PostgreSQL Row Constructors + <https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS>`_ + + `PostgreSQL Row Constructor Comparison + <https://www.postgresql.org/docs/current/functions-comparisons.html#ROW-WISE-COMPARISON>`_ + +Table Types +^^^^^^^^^^^ + +PostgreSQL also supports passing a table as an argument to a function. This +is not available yet in sqlalchemy, however the +:func:`_expression.literal_column` function with the name of the table may be +used in its place:: + + select(['*']).select_from(func.my_function(literal_column('my_table'))) + +Will generate the SQL:: + + SELECT * + FROM my_function(my_table) + ARRAY Types ----------- |