]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
various improvements to the docs
authorFederico Caselli <cfederico87@gmail.com>
Mon, 24 Feb 2025 19:56:38 +0000 (20:56 +0100)
committerFederico Caselli <cfederico87@gmail.com>
Mon, 24 Feb 2025 19:56:38 +0000 (20:56 +0100)
- remove references to the removed mypy plugin
- add create table with partition examples in mysql

Change-Id: Idc5c35519a0812f1d63be95c14afb9ce2b00ea93

doc/build/changelog/changelog_14.rst
doc/build/changelog/migration_20.rst
doc/build/changelog/whatsnew_20.rst
doc/build/errors.rst
doc/build/orm/declarative_tables.rst
lib/sqlalchemy/dialects/mysql/base.py
lib/sqlalchemy/orm/decl_api.py

index 1c41c586c47c91abbd01b80d056fc8251d68f9c5..e2d2f4d6c922468268d95e16f078b2284f9cad42 100644 (file)
@@ -170,7 +170,7 @@ This document details individual issue-level changes made throughout
 
         .. seealso::
 
-            :ref:`mypy_toplevel`
+            mypy_toplevel -- section was removed
 
 .. changelog::
     :version: 1.4.52
@@ -5683,7 +5683,7 @@ This document details individual issue-level changes made throughout
 
         .. seealso::
 
-            :ref:`mypy_declarative_mixins`
+            mypy_declarative_mixins -- section was removed
 
 
     .. change::
@@ -6337,7 +6337,7 @@ This document details individual issue-level changes made throughout
 
         .. seealso::
 
-            :ref:`mypy_toplevel`
+            mypy_toplevel -- section was removed
 
     .. change::
         :tags: bug, sql
index 523eb638101f1511a971c8275d997b711ce7a5cf..70dd6c41197b4751c672ad3c88c3365408b3eda1 100644 (file)
@@ -458,7 +458,7 @@ of the :class:`_orm.Mapped` generic container.  Annotations which don't use
 :class:`_orm.Mapped` which link to constructs such as :func:`_orm.relationship`
 will raise errors in Python, as they suggest mis-configurations.
 
-SQLAlchemy applications that use the :ref:`Mypy plugin <mypy_toplevel>` with
+SQLAlchemy applications that use the Mypy plugin with
 explicit annotations that don't use :class:`_orm.Mapped` in their annotations
 are subject to these errors, as would occur in the example below::
 
index 5ff98646ddbe42e6faa41d4c0ca41a6fa8977334..f7c2b74f0311e4ce0fb0da463e5fb822454c0945 100644 (file)
@@ -368,7 +368,7 @@ ORM Declarative Models
 ~~~~~~~~~~~~~~~~~~~~~~
 
 SQLAlchemy 1.4 introduced the first SQLAlchemy-native ORM typing support
-using a combination of sqlalchemy2-stubs_ and the :ref:`Mypy Plugin <mypy_toplevel>`.
+using a combination of sqlalchemy2-stubs_ and the Mypy Plugin.
 In SQLAlchemy 2.0, the Mypy plugin **remains available, and has been updated
 to work with SQLAlchemy 2.0's typing system**.  However, it should now be
 considered **deprecated**, as applications now have a straightforward path to adopting the
@@ -729,7 +729,7 @@ and :class:`_engine.Row` objects::
 Using Legacy Mypy-Typed Models
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-SQLAlchemy applications that use the :ref:`Mypy plugin <mypy_toplevel>` with
+SQLAlchemy applications that use the Mypy plugin with
 explicit annotations that don't use :class:`_orm.Mapped` in their annotations
 are subject to errors under the new system, as such annotations are flagged as
 errors when using constructs such as :func:`_orm.relationship`.
index 237d5d0ab3ba56c92164577b843e632285b16566..e3ba5cce8f16be7df67fe29ed5c0953cc30a9203 100644 (file)
@@ -1384,7 +1384,7 @@ annotations within class definitions at runtime. A requirement of this form is
 that all ORM annotations must make use of a generic container called
 :class:`_orm.Mapped` to be properly annotated. Legacy SQLAlchemy mappings which
 include explicit :pep:`484` typing annotations, such as those which use the
-:ref:`legacy Mypy extension <mypy_toplevel>` for typing support, may include
+legacy Mypy extension for typing support, may include
 directives such as those for :func:`_orm.relationship` that don't include this
 generic.
 
index 9619c5b253aae52344bc48fe8a98430513d3d73c..bbac1ea101adc2ad2e57fdcdc8508d4ebda07d84 100644 (file)
@@ -423,7 +423,7 @@ allow mapping database types that can support multiple Python types, such as
 
 The above example maps the union of ``list[int]`` and ``list[str]`` to the Postgresql
 :class:`_postgresql.JSONB` datatype, while naming a union of ``float,
-str, bool`` will match to the :class:`.JSON` datatype.   An equivalent
+str, bool`` will match to the :class:`_types.JSON` datatype.   An equivalent
 union, stated in the :class:`_orm.Mapped` construct, will match into the
 corresponding entry in the type map.
 
index 96eecc2ba67fa86a2d4d13e66503043475821e05..b57a1e134371cb765152e347ec38e15d63b6352a 100644 (file)
@@ -182,6 +182,31 @@ For fully atomic transactions as well as support for foreign key
 constraints, all participating ``CREATE TABLE`` statements must specify a
 transactional engine, which in the vast majority of cases is ``InnoDB``.
 
+Partitioning can similarly be specified using similar options.
+In the example below the create table will specify ``PARTITION_BY``,
+``PARTITIONS``, ``SUBPARTITIONS`` and ``SUBPARTITION_BY``::
+
+    # can also use mariadb_* prefix
+    Table(
+        "testtable",
+        MetaData(),
+        Column("id", Integer(), primary_key=True, autoincrement=True),
+        Column("other_id", Integer(), primary_key=True, autoincrement=False),
+        mysql_partitions="2",
+        mysql_partition_by="KEY(other_id)",
+        mysql_subpartition_by="HASH(some_expr)",
+        mysql_subpartitions="2",
+    )
+
+This will render:
+
+.. sourcecode:: sql
+
+    CREATE TABLE testtable (
+            id INTEGER NOT NULL AUTO_INCREMENT,
+            other_id INTEGER NOT NULL,
+            PRIMARY KEY (id, other_id)
+    )PARTITION BY KEY(other_id) PARTITIONS 2 SUBPARTITION BY HASH(some_expr) SUBPARTITIONS 2
 
 Case Sensitivity and Table Reflection
 -------------------------------------
index 97da200ef3a302d3d20296cd9282afbb98a2df73..e01ad61362c3bcb92731e2b0af5a69f0a91f18d6 100644 (file)
@@ -503,7 +503,7 @@ def declarative_mixin(cls: Type[_T]) -> Type[_T]:
 
     The :func:`_orm.declarative_mixin` decorator currently does not modify
     the given class in any way; it's current purpose is strictly to assist
-    the :ref:`Mypy plugin <mypy_toplevel>` in being able to identify
+    the Mypy plugin in being able to identify
     SQLAlchemy declarative mixin classes when no other context is present.
 
     .. versionadded:: 1.4.6
@@ -512,9 +512,6 @@ def declarative_mixin(cls: Type[_T]) -> Type[_T]:
 
         :ref:`orm_mixins_toplevel`
 
-        :ref:`mypy_declarative_mixins` - in the
-        :ref:`Mypy plugin documentation <mypy_toplevel>`
-
     """  # noqa: E501
 
     return cls