Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
f05aa94a by Kunal Mehta at 2021-07-06T18:52:17-07:00
Switch autoresponse_text fields to Text

The autoresponse_text fields are too small in MySQL: only VARCHAR(255).

Make them bigger following the same treatment that info got in 01e871cb5
by switching them to the SAText type.

While we're at it, change SAText to use the utf8mb4 collation on MySQL.
I'm unsure why it was skipped in 10f6f8976, but I don't see any reason
not to do it now.

Fixes #925 and #891.

- - - - -
63c5c9a8 by Mark Sapiro at 2021-07-11T09:06:44-07:00
Merge branch 'legoktm/mailman-autoresponse-text'

Switch autoresponse_text fields to Text

See merge request mailman/mailman!888

- - - - -


4 changed files:

- + 
src/mailman/database/alembic/versions/98224512c9c2_mysql_extend_autoresponse_text_fields_.py
- src/mailman/database/types.py
- src/mailman/docs/NEWS.rst
- src/mailman/model/mailinglist.py


Changes:

=====================================
src/mailman/database/alembic/versions/98224512c9c2_mysql_extend_autoresponse_text_fields_.py
=====================================
@@ -0,0 +1,84 @@
+# Copyright (C) 2020-2021 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman.  If not, see <https://www.gnu.org/licenses/>.
+
+"""MySQL: Extend autoresponse text fields, use utf8mb4
+
+Revision ID: 98224512c9c2
+Revises: bc0c49c6dda2
+Create Date: 2021-07-06 18:29:14.583453
+
+"""
+from alembic import op
+from mailman.database.helpers import is_mysql
+from mailman.database.types import SAText, SAUnicode4Byte
+from sqlalchemy.dialects import mysql
+
+
+# revision identifiers, used by Alembic.
+revision = '98224512c9c2'
+down_revision = 'bc0c49c6dda2'
+
+
+def upgrade():  # pragma: nocover
+    with op.batch_alter_table('mailinglist', schema=None) as batch_op:
+        batch_op.alter_column(
+            'autoresponse_owner_text',
+            existing_type=SAUnicode4Byte(),
+            type_=SAText(),
+            existing_nullable=True)
+        batch_op.alter_column(
+            'autoresponse_postings_text',
+            existing_type=SAUnicode4Byte(),
+            type_=SAText(),
+            existing_nullable=True)
+        batch_op.alter_column(
+            'autoresponse_request_text',
+            existing_type=SAUnicode4Byte(),
+            type_=SAText(),
+            existing_nullable=True)
+        if is_mysql(op.get_bind()):
+            # MySQL-only, switch info to utf8mb4 charset
+            batch_op.alter_column(
+                'info',
+                existing_type=mysql.TEXT(charset='utf8', collation='utf8_bin'),
+                type_=SAText(),
+                existing_nullable=True)
+
+
+def downgrade():  # pragma: nocover
+    with op.batch_alter_table('mailinglist', schema=None) as batch_op:
+        if is_mysql(op.get_bind()):
+            batch_op.alter_column(
+                'info',
+                existing_type=SAText(),
+                type_=mysql.TEXT(charset='utf8', collation='utf8_bin'),
+                existing_nullable=True)
+        batch_op.alter_column(
+            'autoresponse_request_text',
+            existing_type=SAText(),
+            type_=SAUnicode4Byte(),
+            existing_nullable=True)
+        batch_op.alter_column(
+            'autoresponse_postings_text',
+            existing_type=SAText(),
+            type_=SAUnicode4Byte(),
+            existing_nullable=True)
+        batch_op.alter_column(
+            'autoresponse_owner_text',
+            existing_type=SAText(),
+            type_=SAUnicode4Byte(),
+            existing_nullable=True)


=====================================
src/mailman/database/types.py
=====================================
@@ -183,7 +183,7 @@ def default_sa_unicode_xl(element, compiler, **kw):
 class SAText(TypeDecorator):
     """Text datatype to support large text content in MySQL.
 
-    This type compiles to TEXT COLLATE utf8_bin in case of MySQL, and in
+    This type compiles to TEXT COLLATE utf8mb4_bin in case of MySQL, and in
     case of other dialects defaults to the Text type.
     """
     impl = Text
@@ -197,4 +197,4 @@ def default_sa_text(element, compiler, **kw):
 @compiles(SAText, 'mysql')
 def compile_sa_text(element, compiler, **kw):
     # We hardcode the collate here to make string comparison case sensitive.
-    return 'TEXT COLLATE utf8_bin'                        # pragma: nocover
+    return 'TEXT COLLATE utf8mb4_bin'                     # pragma: nocover


=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -52,8 +52,9 @@ Bugs
   prod.outlook.com are now handled without shunting the message.  (Closes #885)
 * Command runner now will decode the message body before processing it.
   (Closes #859)
-* The ``mailinglist`` table ``info`` column is changed to Text.  (Closes #840
-  and #886)
+* The ``mailinglist`` table ``info``, ``autoresponse_owner_text``,
+  ``autoresponse_postings_text`` and ``autoresponse_request_text`` columns are
+  changed to Text.  (Closes #840, #886 and #925)
 * The mailing list administrators roster ``get_member()`` method now returns
   the owner if the target is both an owner and moderator.  (Closes #888)
 * Command runner now handles RFC 2047 encoded command with non-ascii prefix.


=====================================
src/mailman/model/mailinglist.py
=====================================
@@ -110,11 +110,11 @@ class MailingList(Model):
     # Automatic responses.
     autoresponse_grace_period = Column(Interval)
     autorespond_owner = Column(Enum(ResponseAction))
-    autoresponse_owner_text = Column(SAUnicode4Byte)
+    autoresponse_owner_text = Column(SAText)
     autorespond_postings = Column(Enum(ResponseAction))
-    autoresponse_postings_text = Column(SAUnicode4Byte)
+    autoresponse_postings_text = Column(SAText)
     autorespond_requests = Column(Enum(ResponseAction))
-    autoresponse_request_text = Column(SAUnicode4Byte)
+    autoresponse_request_text = Column(SAText)
     # Content filters.
     filter_action = Column(Enum(FilterAction))
     filter_content = Column(Boolean)



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/04b86690814588fc6f9f7b410dfef492604ce545...63c5c9a8504e0a2af1c69252c50fe6b0271700a2

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/04b86690814588fc6f9f7b410dfef492604ce545...63c5c9a8504e0a2af1c69252c50fe6b0271700a2
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to