summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Zeidler <andi@pyfidelity.com>2014-01-31 17:21:07 +0100
committerAndreas Zeidler <andi@pyfidelity.com>2014-01-31 17:21:07 +0100
commit41e40d9261bbae2c970959f0b03691fccfd0cddf (patch)
tree3af25ef23bf5d302a4b51d03e40c382cdec3528f
parent66fe0880bae38b09ba94188ee1c67391c667e64b (diff)
downloadsqlalchemy-pr/62.tar.gz
allow enums with a lot of labels by passing them as a listpr/62
otherwise very long enums might cause a `SyntaxError: more than 255 arguments`
-rw-r--r--lib/sqlalchemy/types.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py
index a9e015153..ed87be89b 100644
--- a/lib/sqlalchemy/types.py
+++ b/lib/sqlalchemy/types.py
@@ -1985,6 +1985,8 @@ class Enum(String, SchemaType):
:param \*enums: string or unicode enumeration labels. If unicode
labels are present, the `convert_unicode` flag is auto-enabled.
+ It is also possible to pass one list in case there are more than
+ 255 labels, causing a syntax error.
:param convert_unicode: Enable unicode-aware bind parameter and
result-set processing for this Enum's data. This is set
@@ -2036,6 +2038,8 @@ class Enum(String, SchemaType):
.. versionadded:: 0.8
"""
+ if len(enums) == 1 and isinstance(enums[0], (list, tuple)):
+ enums = enums[0]
self.enums = enums
self.native_enum = kw.pop('native_enum', True)
convert_unicode = kw.pop('convert_unicode', None)