]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add explicit warning re: mapped_column.default
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 23 Jun 2023 14:45:12 +0000 (10:45 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 23 Jun 2023 14:45:12 +0000 (10:45 -0400)
Change-Id: I3ac7133323a02cb70e20de2fd96cc31842ead4f1
References: #9936
References: #10009

lib/sqlalchemy/orm/_orm_constructors.py

index fab93f68242647c36b4e47b3121f077ead0f16b4..b5586350d0ec0f97e2173b570925eae47b75d397 100644 (file)
@@ -246,6 +246,15 @@ def mapped_column(
      :class:`_sql.Insert` construct would use in any case, leading to the same
      end result.
 
+     .. note:: When using Core level column defaults that are callables to
+        be interpreted by the underlying :class:`_schema.Column` in conjunction
+        with :ref:`ORM-mapped dataclasses
+        <orm_declarative_native_dataclasses>`, especially those that are
+        :ref:`context-aware default functions <context_default_functions>`,
+        **the** :paramref:`_orm.mapped_column.insert_default` **parameter must
+        be used instead**.  This is necessary to disambiguate the callable from
+        being interpreted as a dataclass level default.
+
     :param insert_default: Passed directly to the
      :paramref:`_schema.Column.default` parameter; will supersede the value
      of :paramref:`_orm.mapped_column.default` when present, however