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

Updating ForeignKey with non-existing reference breaks functionality. #1

Open
MiguelSR opened this issue Jul 19, 2017 · 0 comments
Open

Comments

@MiguelSR
Copy link

MiguelSR commented Jul 19, 2017

When you try to update some element's foreign key providing an invalid value (i.e. not existing in the related table), it's stored anyway in DB and prevent you to do further operations on that element.

Example:

# Valid request

/usr/src/app # python -m my_module config url update 1 --force --client 1
Changed 1 records.

client  <Client id=1>
id      1
path    'foo'

# Bad request

/usr/src/app # python -m my_module config url update 1 --force --client -1
[...]
bugloader.models.ClientDoesNotExist: Instance matching query does not exist:
SQL: SELECT "t1"."id", "t1"."name" FROM "client" AS t1 WHERE ("t1"."id" = ?)
PARAMS: [-1]

From this moment every single operation gives an error, unless you pass the "-f" option to update the field or delete the row.

@MiguelSR MiguelSR changed the title Updating ForeignKey with non-existing reference brokes functionality. Updating ForeignKey with non-existing reference breaks functionality. Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant