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

Fix testing Rule query before saving #510

Merged
merged 1 commit into from
May 16, 2024

Conversation

vincent-olivert-riera
Copy link
Contributor

@vincent-olivert-riera vincent-olivert-riera commented May 15, 2024

When creating a new Rule and testing its query before saving it, an error like this was happening:

'Rule' instance needs to have a primary key value before this relationship can
be used.

From the user's perspective, the test was not happening and the server returned a 500 error.

When testing a new Rule that has not been saved, a temporary Rule object is created in memory. Since that object is not saved, it does not contain a primary key.

Due to some changes introduced in Django 4, errors are thrown if that object without a primary key is used. To fix that issue, we manually assign a primary key.

When creating a new Rule and testing its query before saving it, an error like
this was happening:

  'Rule' instance needs to have a primary key value before this relationship can
  be used.

From the user's perspective, the test was not happening and the server returned
a 500 error.

When testing a new Rule that has not been saved, a temporary Rule object is
created in memory. Since that object is not saved, it does not contain a primary
key.

Due to some changes introduced in Django 4, errors are thrown if that object
without a primary key is used. To fix that issue, we manually assign a primary
key.
@vincent-olivert-riera vincent-olivert-riera requested a review from a team as a code owner May 15, 2024 02:32
@vincent-olivert-riera vincent-olivert-riera merged commit 88cba05 into master May 16, 2024
5 checks passed
@vincent-olivert-riera vincent-olivert-riera deleted the fix-test-query-before-saving-rule branch May 16, 2024 07:48
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

Successfully merging this pull request may close these issues.

2 participants