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
Describe the bug
When I try to filter model by foreign key's column value and update, I get this error.
To Reproduce
bug_models.py
from tortoise import Model, fields
class Email(Model):
value = fields.CharField(255)
class Meta:
table = 'emails'
class User(Model):
email = fields.OneToOneField('models.Email', related_name='user')
class Meta:
table = 'users'
I have same issue, it seems that SQL produced for update is invalid when there is also a left join.
I grabbed generated SQL for my case, the left outer join clause should be after SET not before.
UPDATE "lampdescriptor"
LEFT OUTER JOIN "peripheraldescriptor" "lampdescriptor__descriptor"
ON "lampdescriptor__descriptor"."id"="lampdescriptor"."descriptor_id"
SET "last_func_test_time"='2022-03-09 10:10:27.672996+00:00',"last_func_test_result"=0
WHERE "lampdescriptor__descriptor"."peripheral_id"=2
Describe the bug
When I try to filter model by foreign key's column value and update, I get this error.
To Reproduce
bug_models.py
main.py
Expected behavior
Update all Email records where their user's id is 1
Additional context
...
The text was updated successfully, but these errors were encountered: