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 using multiple nested levels of create or include, the pylance syntax highlighting is incorrect. For instance, it highlights a second level of create as a reportArgumentType error even though it will execute perfectly fine.
Perhaps this is user error, but I believe I have everything set up correctly with recursive types etc.
How to reproduce
fromprismaimportPrismafromprisma.modelsimportChild, Parent, SubChildasyncdefmain():
"""This is the main function that runs the demo."""db=Prisma(auto_register=True)
awaitdb.connect()
# delete everything in the dbawaitParent.prisma().delete_many()
awaitChild.prisma().delete_many()
awaitSubChild.prisma().delete_many()
asyncwithdb.tx() astx:
arthur=awaitParent.prisma(tx).create(
data={
"name": "Arthur",
"child": {
"create": {
"name": "Billie",
# this incorrectly shows a pylance error, since multiple nested creates do work.# [reportArgumentType: subChild is an undefined item in type "ChildCreateWithoutRelationsInput"]"subChild": {
"create": {
"name": "Carl",
},
},
},
},
},
include={
"child": {
"include": {
"subChild": True,
},
},
},
)
print(arthur.child.subChild.name)
asyncdefcreate_parent(db: Prisma):
"""Some examples of syntax highlighting behavior."""asyncwithdb.tx() astx:
awaitParent.prisma(tx).create(
data={
"name": "Adam",
# This should show a pylance/pyright error because there is no childId or child:create
}
)
awaitParent.prisma(tx).create(
data={
# This correctly shows a pylance/pyright error because there is an incorrect field name# [reportArgumentType: nam is an undefined item in type "ParentCreateInput"]"nam": "Alex",
"child": {
"create": {
"name": "Bob",
},
},
}
)
awaitParent.prisma(tx).create(
# this correctly shows a pylance/pyright error because there is no name# [reportArgumentType: name is required in "ParentCreateInput"]data={
"child": {
"create": {
"name": "Bob",
},
},
}
)
awaitParent.prisma(tx).create(
data={
"name": "Alfred",
"child": {
"create": {
# this should show an error because the subchild is not defined"name": "Bob",
},
},
}
)
awaitParent.prisma(tx).create(
data={
"name": "Andy",
"child": {
"create": {
"name": "Bob",
# this incorrectly shows a pylance error, since multiple nested creates do work.# [reportArgumentType: subChild is an undefined item in type "ChildCreateWithoutRelationsInput"]"subChild": {
"create": {
"name": "Charlie",
},
},
},
},
}
)
arthur=awaitParent.prisma(tx).create(
data={
"name": "Arthur",
"child": {
"create": {
"name": "Billie",
# this incorrectly shows a pylance error, since multiple nested creates do work.# [reportArgumentType: subChild is an undefined item in type "ChildCreateWithoutRelationsInput"]"subChild": {
"create": {
"name": "Carl",
},
},
},
},
},
include={
"child": {
"include": {
"subChild": True,
},
},
},
)
# this incorrectly shows a syntax error, since child:include:subChild:True and child/childId are not optional in parent# and subChild/subChildId are not optional in child.carls_name=arthur.child.subChild.nameprint(carls_name)
if__name__=="__main__":
importasyncioasyncio.run(main())
Expected behavior
No errors to show when accessing an object returned from a select when using multiple levels of include on fields that are all fully required in the schema.
An error to show when creating a record with a relation that is required but not present
No error shows when creating a second level of nested creates.
Bug description
When using multiple nested levels of
create
orinclude
, the pylance syntax highlighting is incorrect. For instance, it highlights a second level ofcreate
as areportArgumentType
error even though it will execute perfectly fine.Perhaps this is user error, but I believe I have everything set up correctly with recursive types etc.
How to reproduce
Expected behavior
Prisma information
Environment & setup
The text was updated successfully, but these errors were encountered: