summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-10-20 15:59:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-10-20 15:59:46 -0400
commitc97b1b82282553d42e5893a094926602b0a2406d (patch)
tree769eac8dff3690536e8511ff80493239626056f0 /test/sql
parent30bd28fca2091e4b2b093154a14c668c09ae3ccd (diff)
downloadsqlalchemy-c97b1b82282553d42e5893a094926602b0a2406d.tar.gz
Convert expression type for concat + Enum
Fixed bug involving new value translation and validation feature in :class:`.Enum` whereby using the enum object in a string concatenation would maintain the :class:`.Enum` type as the type of the expression overall, producing missing lookups. A string concatenation against an :class:`.Enum`-typed column now uses :class:`.String` as the datatype of the expression itself. Change-Id: Id402054e3ef008e0250c740dbb7e1c80f339fe78 Fixes: #3833
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_types.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/sql/test_types.py b/test/sql/test_types.py
index 3374a6721..7f49991e6 100644
--- a/test/sql/test_types.py
+++ b/test/sql/test_types.py
@@ -1264,6 +1264,25 @@ class EnumTest(AssertsCompiledSQL, fixtures.TablesTest):
]
)
+ def test_validators_not_in_concatenate_roundtrip(self):
+ enum_table = self.tables['non_native_enum_table']
+
+ enum_table.insert().execute([
+ {'id': 1, 'someenum': 'two'},
+ {'id': 2, 'someenum': 'two'},
+ {'id': 3, 'someenum': 'one'},
+ ])
+
+ eq_(
+ select(['foo' + enum_table.c.someenum]).
+ order_by(enum_table.c.id).execute().fetchall(),
+ [
+ ('footwo', ),
+ ('footwo', ),
+ ('fooone', )
+ ]
+ )
+
@testing.fails_on(
'postgresql+zxjdbc',
'zxjdbc fails on ENUM: column "XXX" is of type XXX '