From eec1a7f6e9157fd750e31d28a28705a1b928865a Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:59:03 -0400 Subject: [PATCH] services/postgresql: Use functions as defaults instead of mutable types --- docs/services/postgresql.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/services/postgresql.rst b/docs/services/postgresql.rst index 21f8a47..da4e07c 100644 --- a/docs/services/postgresql.rst +++ b/docs/services/postgresql.rst @@ -39,6 +39,7 @@ Define tables - In PostgreSQL, use ``TEXT`` instead of other character types, as there is `no performance difference `__. - Use ``NOT NULL`` with character types, `as recommended by Django `__. - Use ``NOT NULL`` with JSON types, and set the default to an empty object, array or string. +- In Python, do not set default values to ``{}`` or ``[]``. In Django, use ``default=dict`` and ``default=list``. In Pydantic (including SQLModel), use ``default_factory=dict`` and ``default_factory=list``. .. seealso::