From e7126badadf4995d8a946cd9ed89e3697f7d010f Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 24 Jul 2024 14:15:12 -0700 Subject: [PATCH] Add pydantic_disable_protected_namespaces to Config Fixes: GH-982 --- src/prisma/generator/models.py | 2 ++ src/prisma/generator/templates/bases.py.jinja | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/prisma/generator/models.py b/src/prisma/generator/models.py index 99a0d9878..687c8015f 100644 --- a/src/prisma/generator/models.py +++ b/src/prisma/generator/models.py @@ -506,6 +506,8 @@ class Config(BaseSettings): # https://github.com/prisma/prisma/issues/12442 enable_experimental_decimal: bool = FieldInfo(default=False, env='PRISMA_PY_CONFIG_ENABLE_EXPERIMENTAL_DECIMAL') + pydantic_disable_protected_namespaces: bool = False + # this seems to be the only good method for setting the contextvar as # we don't control the actual construction of the object like we do for # the Data model. diff --git a/src/prisma/generator/templates/bases.py.jinja b/src/prisma/generator/templates/bases.py.jinja index d0ce43165..17a957707 100644 --- a/src/prisma/generator/templates/bases.py.jinja +++ b/src/prisma/generator/templates/bases.py.jinja @@ -21,6 +21,9 @@ class _PrismaModel(BaseModel): use_enum_values=True, arbitrary_types_allowed=True, populate_by_name=True, +{% if generator.config.pydantic_disable_protected_namespaces %} + protected_namespaces=(), +{% endif %} ) elif not TYPE_CHECKING: from ._compat import BaseConfig