You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When importing the generated client an error is thrown
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'A'
I suspect because the 'models' field name is clashing with the models namespace for the pydantic models. Removing the namespace in the client and referring directly to the prisma model allows the import to work
e.g from
classB(bases.BaseB):
"""Represents a B record"""id: _intmodels: Optional[List['models.A']] =None
to
classB(bases.BaseB):
"""Represents a B record"""id: _intmodels: Optional[List['A']] =None
How to reproduce
Create the above schema as prisma.schema
uv init
uv add prisma
uv run python -m prisma generate --schema prisma.schema
uv run python -c 'import prisma'
Expected behavior
The client to be able to import and retain a field called 'models' on B
Prisma information
see above
Environment & setup
OS: Mac
Database: MySQL also tested with SQLite
Python version: Python 3.10.0, also tested with 3.11 and 3.13
Bug description
Given a schema
When importing the generated client an error is thrown
I suspect because the 'models' field name is clashing with the models namespace for the pydantic models. Removing the namespace in the client and referring directly to the prisma model allows the import to work
e.g from
to
How to reproduce
Create the above schema as prisma.schema
Expected behavior
The client to be able to import and retain a field called 'models' on B
Prisma information
see above
Environment & setup
The text was updated successfully, but these errors were encountered: