Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(generator): add pydantic_disable_protected_namespaces config #983

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/prisma/generator/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/prisma/generator/templates/bases.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading