summaryrefslogtreecommitdiff
path: root/test/dialect
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2023-04-29 12:07:32 +0200
committerMike Bayer <mike_mp@zzzcomputing.com>2023-04-30 11:14:22 -0400
commit23a4538b0b1e750d09392e1c7eca67b1356294d8 (patch)
tree920641296ff3cd064cf0b33673475a1427d11499 /test/dialect
parent39c8e95b1f50190ff30a836b2bcf13ba2cacc052 (diff)
downloadsqlalchemy-23a4538b0b1e750d09392e1c7eca67b1356294d8.tar.gz
Support control char reflection in mysql mariadb
Fixed issues regarding reflection of comments for :class:`_schema.Table` and :class:`_schema.Column` objects, where the comments contained control characters such as newlines. Additional testing support for these characters as well as extended Unicode characters in table and column comments (the latter of which aren't supported by MySQL/MariaDB) added to testing overall. Fixes: #9722 Change-Id: Id18bf758fdb6231eb705c61eeaf74bb9fa472601
Diffstat (limited to 'test/dialect')
-rw-r--r--test/dialect/mysql/test_reflection.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/dialect/mysql/test_reflection.py b/test/dialect/mysql/test_reflection.py
index f9975a973..a75c05f09 100644
--- a/test/dialect/mysql/test_reflection.py
+++ b/test/dialect/mysql/test_reflection.py
@@ -1368,6 +1368,29 @@ class ReflectionTest(fixtures.TestBase, AssertsCompiledSQL):
},
)
+ def test_reflect_comment_escapes(self, connection, metadata):
+ c = "\\ - \\\\ - \\0 - \\a - \\b - \\t - \\n - \\v - \\f - \\r"
+ Table("t", metadata, Column("c", Integer, comment=c), comment=c)
+ metadata.create_all(connection)
+
+ insp = inspect(connection)
+ tc = insp.get_table_comment("t")
+ eq_(tc, {"text": c})
+ col = insp.get_columns("t")[0]
+ eq_({col["name"]: col["comment"]}, {"c": c})
+
+ def test_reflect_comment_unicode(self, connection, metadata):
+ c = "☁️✨🐍🁰🝝"
+ c_exp = "☁️✨???"
+ Table("t", metadata, Column("c", Integer, comment=c), comment=c)
+ metadata.create_all(connection)
+
+ insp = inspect(connection)
+ tc = insp.get_table_comment("t")
+ eq_(tc, {"text": c_exp})
+ col = insp.get_columns("t")[0]
+ eq_({col["name"]: col["comment"]}, {"c": c_exp})
+
class RawReflectionTest(fixtures.TestBase):
def setup_test(self):