series as well. For changes that are specific to 1.0 with an emphasis
on compatibility concerns, see :doc:`/changelog/migration_10`.
+ .. change::
+ :tags: bug, postgresql
+ :tickets: 3264
+
+ The :meth:`.PGDialect.has_table` method will now query against
+ ``pg_catalog.pg_table_is_visible(c.oid)``, rather than testing
+ for an exact schema match, when the schema name is None; this
+ so that the method will also illustrate that temporary tables
+ are present. Note that this is a behavioral change, as Postgresql
+ allows a non-temporary table to silently overwrite an existing
+ temporary table of the same name, so this changes the behavior
+ of ``checkfirst`` in that unusual scenario.
+
+ .. seealso::
+
+ :ref:`change_3264`
+
.. change::
:tags: bug, sql
:tickets: 3260
:ticket:`2891`
+.. _change_3264:
+
+Postgresql ``has_table()`` now works for temporary tables
+---------------------------------------------------------
+
+This is a simple fix such that "has table" for temporary tables now works,
+so that code like the following may proceed::
+
+ from sqlalchemy import *
+
+ metadata = MetaData()
+ user_tmp = Table(
+ "user_tmp", metadata,
+ Column("id", INT, primary_key=True),
+ Column('name', VARCHAR(50)),
+ prefixes=['TEMPORARY']
+ )
+
+ e = create_engine("postgresql://scott:tiger@localhost/test", echo='debug')
+ with e.begin() as conn:
+ user_tmp.create(conn, checkfirst=True)
+
+ # checkfirst will succeed
+ user_tmp.create(conn, checkfirst=True)
+
+The very unlikely case that this behavior will cause a non-failing application
+to behave differently, is because Postgresql allows a non-temporary table
+to silently overwrite a temporary table. So code like the following will
+now act completely differently, no longer creating the real table following
+the temporary table::
+
+ from sqlalchemy import *
+
+ metadata = MetaData()
+ user_tmp = Table(
+ "user_tmp", metadata,
+ Column("id", INT, primary_key=True),
+ Column('name', VARCHAR(50)),
+ prefixes=['TEMPORARY']
+ )
+
+ e = create_engine("postgresql://scott:tiger@localhost/test", echo='debug')
+ with e.begin() as conn:
+ user_tmp.create(conn, checkfirst=True)
+
+ m2 = MetaData()
+ user = Table(
+ "user_tmp", m2,
+ Column("id", INT, primary_key=True),
+ Column('name', VARCHAR(50)),
+ )
+
+ # in 0.9, *will create* the new table, overwriting the old one.
+ # in 1.0, *will not create* the new table
+ user.create(conn, checkfirst=True)
+
+:ticket:`3264`
+
.. _feature_gh134:
Postgresql FILTER keyword
t2 = Table('t', m2, autoload=True)
eq_([c.name for c in t2.primary_key], ['t_id'])
+ @testing.provide_metadata
+ def test_has_temporary_table(self):
+ assert not testing.db.has_table("some_temp_table")
+ user_tmp = Table(
+ "some_temp_table", self.metadata,
+ Column("id", Integer, primary_key=True),
+ Column('name', String(50)),
+ prefixes=['TEMPORARY']
+ )
+ user_tmp.create(testing.db)
+ assert testing.db.has_table("some_temp_table")
+
@testing.provide_metadata
def test_cross_schema_reflection_one(self):