summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-10-21 16:33:04 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-10-21 16:33:04 +0000
commite552ce339e9ee4fe2c8adf2298d7bba94ba817ac (patch)
tree84ef1de5ee031aeb7d48224ae20645fe6551c609 /lib/sqlalchemy/dialects/postgresql
parent5a140299b3ec6c7d800484fd6b5acedacc4aabb7 (diff)
downloadsqlalchemy-e552ce339e9ee4fe2c8adf2298d7bba94ba817ac.tar.gz
- RETURNING is supported by 8.2+
- add docs for PG delete..returning
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 061c3b066..3c905e7d5 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -32,14 +32,14 @@ that when an :func:`~sqlalchemy.sql.expression.insert()` construct is executed u
"executemany" semantics, the sequence is not pre-executed and normal PG SERIAL behavior
is used.
-PostgreSQL 8.3 supports an ``INSERT...RETURNING`` syntax which SQLAlchemy supports
+PostgreSQL 8.2 supports an ``INSERT...RETURNING`` syntax which SQLAlchemy supports
as well. A future release of SQLA will use this feature by default in lieu of
sequence pre-execution in order to retrieve new primary key values, when available.
INSERT/UPDATE...RETURNING
-------------------------
-The dialect supports PG 8.3's ``INSERT..RETURNING`` and ``UPDATE..RETURNING`` syntaxes,
+The dialect supports PG 8.2's ``INSERT..RETURNING``, ``UPDATE..RETURNING`` and ``DELETE..RETURNING`` syntaxes,
but must be explicitly enabled on a per-statement basis::
# INSERT..RETURNING
@@ -52,6 +52,11 @@ but must be explicitly enabled on a per-statement basis::
where(table.c.name=='foo').values(name='bar')
print result.fetchall()
+ # DELETE..RETURNING
+ result = table.delete().returning(table.c.col1, table.c.col2).\\
+ where(table.c.name=='foo')
+ print result.fetchall()
+
Indexes
-------
@@ -468,7 +473,7 @@ class PGDialect(default.DefaultDialect):
def initialize(self, connection):
super(PGDialect, self).initialize(connection)
- self.implicit_returning = self.server_version_info > (8, 3) and \
+ self.implicit_returning = self.server_version_info > (8, 2) and \
self.__dict__.get('implicit_returning', True)
def visit_pool(self, pool):