summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-03-11 11:41:52 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-03-11 11:41:52 -0400
commit71b8df2e5319773008e83f784543a716a80d7511 (patch)
tree34be669b9a518d7dc6f52c043a24597498dedc36 /doc
parent710021d22e8a5a053e1c4edc4a30612f6e10b83e (diff)
downloadsqlalchemy-71b8df2e5319773008e83f784543a716a80d7511.tar.gz
- The Postgresql :class:`.postgresql.ENUM` type will emit a
DROP TYPE instruction when a plain ``table.drop()`` is called, assuming the object is not associated directly with a :class:`.MetaData` object. In order to accomodate the use case of an enumerated type shared between multiple tables, the type should be associated directly with the :class:`.MetaData` object; in this case the type will only be created at the metadata level, or if created directly. The rules for create/drop of Postgresql enumerated types have been highly reworked in general. fixes #3319
Diffstat (limited to 'doc')
-rw-r--r--doc/build/changelog/changelog_10.rst18
-rw-r--r--doc/build/changelog/migration_10.rst51
2 files changed, 69 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst
index 1776625f8..ca9aa1b7e 100644
--- a/doc/build/changelog/changelog_10.rst
+++ b/doc/build/changelog/changelog_10.rst
@@ -24,6 +24,24 @@
on compatibility concerns, see :doc:`/changelog/migration_10`.
.. change::
+ :tags: bug, postgresql
+ :tickets: 3319
+
+ The Postgresql :class:`.postgresql.ENUM` type will emit a
+ DROP TYPE instruction when a plain ``table.drop()`` is called,
+ assuming the object is not associated directly with a
+ :class:`.MetaData` object. In order to accomodate the use case of
+ an enumerated type shared between multiple tables, the type should
+ be associated directly with the :class:`.MetaData` object; in this
+ case the type will only be created at the metadata level, or if
+ created directly. The rules for create/drop of
+ Postgresql enumerated types have been highly reworked in general.
+
+ .. seealso::
+
+ :ref:`change_3319`
+
+ .. change::
:tags: feature, orm
:tickets: 3317
diff --git a/doc/build/changelog/migration_10.rst b/doc/build/changelog/migration_10.rst
index 66b385cc2..e4f1e0e25 100644
--- a/doc/build/changelog/migration_10.rst
+++ b/doc/build/changelog/migration_10.rst
@@ -1767,6 +1767,57 @@ reflection from temp tables as well, which is :ticket:`3203`.
Dialect Improvements and Changes - Postgresql
=============================================
+.. _change_3319:
+
+Overhaul of ENUM type create/drop rules
+---------------------------------------
+
+The rules for Postgresql :class:`.postgresql.ENUM` have been made more strict
+with regards to creating and dropping of the TYPE.
+
+An :class:`.postgresql.ENUM` that is created **without** being explicitly
+associated with a :class:`.MetaData` object will be created *and* dropped
+corresponding to :meth:`.Table.create` and :meth:`.Table.drop`::
+
+ table = Table('sometable', metadata,
+ Column('some_enum', ENUM('a', 'b', 'c', name='myenum'))
+ )
+
+ table.create(engine) # will emit CREATE TYPE and CREATE TABLE
+ table.drop(engine) # will emit DROP TABLE and DROP TYPE - new for 1.0
+
+This means that if a second table also has an enum named 'myenum', the
+above DROP operation will now fail. In order to accomodate the use case
+of a common shared enumerated type, the behavior of a metadata-associated
+enumeration has been enhanced.
+
+An :class:`.postgresql.ENUM` that is created **with** being explicitly
+associated with a :class:`.MetaData` object will *not* be created *or* dropped
+corresponding to :meth:`.Table.create` and :meth:`.Table.drop`, with
+the exception of :meth:`.Table.create` called with the ``checkfirst=True``
+flag::
+
+ my_enum = ENUM('a', 'b', 'c', name='myenum', metadata=metadata)
+
+ table = Table('sometable', metadata,
+ Column('some_enum', my_enum)
+ )
+
+ # will fail: ENUM 'my_enum' does not exist
+ table.create(engine)
+
+ # will check for enum and emit CREATE TYPE
+ table.create(engine, checkfirst=True)
+
+ table.drop(engine) # will emit DROP TABLE, *not* DROP TYPE
+
+ metadata.drop_all(engine) # will emit DROP TYPE
+
+ metadata.create_all(engine) # will emit CREATE TYPE
+
+
+:ticket:`3319`
+
New Postgresql Table options
-----------------------------