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
If one tries to edit a language object and new values are not presented in the DB then status 500 will be returned.
It happens because we don't check if these new values already exist in the DB. If they're not here then we violate foreign key constraint and an exception is raised:
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) insert or update on table "dictionaryperspective" violates foreign key constraint "dictionaryperspective_parent_object_id_fkey"
We need to add try/catch blocks and return a proper answer.
Example of a problem code:
if language:
if not language.marked_for_deletion:
# TODO: Status 500 will be returned if arguments are invalid; add try/catch
req = request.json_body
if 'parent_client_id' in req:
language.parent_client_id = req['parent_client_id']
if 'parent_object_id' in req:
language.parent_object_id = req['parent_object_id']
if 'translation_gist_client_id' in req:
language.translation_gist_client_id = req['translation_gist_client_id']
if 'translation_gist_object_id' in req:
language.translation_gist_object_id = req['translation_gist_object_id']
request.response.status = HTTPOk.code
return response
The text was updated successfully, but these errors were encountered:
myrix
pushed a commit
to myrix/lingvodoc
that referenced
this issue
Sep 21, 2020
If one tries to edit a language object and new values are not presented in the DB then status 500 will be returned.
It happens because we don't check if these new values already exist in the DB. If they're not here then we violate foreign key constraint and an exception is raised:
We need to add try/catch blocks and return a proper answer.
Example of a problem code:
The text was updated successfully, but these errors were encountered: