]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix some inaccuracies in with_variant doc
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 19 Aug 2022 13:49:25 +0000 (09:49 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 19 Aug 2022 13:52:48 +0000 (09:52 -0400)
* the table wont create on mysql/mariadb b.c. user_name had
  no length
* "utf-8" is not recognized by mysql/mariadb, use "utf8"
* mysql or mariadb name match is determined by the URL, not the
  actual DB that is detected (I know I made it work that way but
  I forgot)
* for the 1.4 backport only, will remove the "mariadb" part
  as we dont support that API, #8408

Fixes: #8408
Change-Id: I5b0a58a3f94a3450631e2405bd07d0a77599ae26
(cherry picked from commit 7f99c4ab55a80ee428b3466e9fa476d6ea03bfaf)

doc/build/core/type_basics.rst

index eb6c8791258ff51b847d61e0fb627f40e290ed2d..49fc715f06f2b716576d3941dc82747f0fb2a419 100644 (file)
@@ -139,7 +139,7 @@ makes use of the :meth:`_types.TypeEngine.with_variant` method in order to
 
 Such as, to use the :class:`_types.String` datatype, but when running on MySQL
 to make use of the :paramref:`_mysql.VARCHAR.charset` parameter of
-:class:`_mysql.VARCHAR` when the table is created on MySQL or MariaDB,
+:class:`_mysql.VARCHAR` when the table is created on MySQL,
 :meth:`_types.TypeEngine.with_variant` may be used as below::
 
     from sqlalchemy import MetaData
@@ -151,16 +151,17 @@ to make use of the :paramref:`_mysql.VARCHAR.charset` parameter of
     user = Table(
         "user",
         metadata_obj,
-        Column("user_name", String, primary_key=True),
+        Column("user_name", String(100), primary_key=True),
         Column(
             "bio",
-            String(255).with_variant(VARCHAR(255, charset="utf-8"), "mysql", "mariadb"),
+            String(255).with_variant(VARCHAR(255, charset="utf8"), "mysql"),
         ),
     )
 
 In the above table definition, the ``"bio"`` column will have string-behaviors
-on all backends.  On most backends it will render in DDL as ``VARCHAR``.
-However on MySQL and MariaDB, it will render as ``VARCHAR(255) CHARACTER SET utf-8``.
+on all backends. On most backends it will render in DDL as ``VARCHAR``. However
+on MySQL (indicated by database URLs that start with ``mysql``), it will
+render as ``VARCHAR(255) CHARACTER SET utf8``.
 
 .. seealso::