]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add a note referring to the enum value as not currently persisted,
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 1 Feb 2017 23:09:45 +0000 (18:09 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 1 Feb 2017 23:09:45 +0000 (18:09 -0500)
reference #3906

Change-Id: I2274c356cc88cd011c5a34a69e75a2548a93e87a

doc/build/changelog/migration_11.rst
lib/sqlalchemy/sql/sqltypes.py

index 04bdd72e99571e57cdd93a1ea5b71aa6f5ea78cb..58ca270274d709593f4a2d15e62745c8aa57f864 100644 (file)
@@ -1505,16 +1505,16 @@ Support for Python's native ``enum`` type and compatible forms
 The :class:`.Enum` type can now be constructed using any
 PEP-435 compliant enumerated type.   When using this mode, input values
 and return values are the actual enumerated objects, not the
-string values::
+string/integer/etc values::
 
     import enum
     from sqlalchemy import Table, MetaData, Column, Enum, create_engine
 
 
     class MyEnum(enum.Enum):
-        one = "one"
-        two = "two"
-        three = "three"
+        one = 1
+        two = 2
+        three = 3
 
 
     t = Table(
index 9b48e839f6d36936ee51aff81b3374ab269772b8..78a130f623ac495f0a8568696abf7380afd6476d 100644 (file)
@@ -1131,9 +1131,9 @@ class Enum(String, SchemaType):
 
         import enum
         class MyEnum(enum.Enum):
-            one = "one"
-            two = "two"
-            three = "three"
+            one = 1
+            two = 2
+            three = 3
 
 
         t = Table(
@@ -1144,6 +1144,11 @@ class Enum(String, SchemaType):
         connection.execute(t.insert(), {"value": MyEnum.two})
         assert connection.scalar(t.select()) is MyEnum.two
 
+    Above, the string names of each element, e.g. "one", "two", "three",
+    are persisted to the database; the values of the Python Enum, here
+    indicated as integers, are **not** used; the value of each enum can
+    therefore be any kind of Python object whether or not it is persistable.
+
     .. versionadded:: 1.1 - support for PEP-435-style enumerated
        classes.