-
Notifications
You must be signed in to change notification settings - Fork 301
WIP: workaround "'PKOnlyObject' object has no attribute" error for toOne related #492
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
Closed
Closed
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e858bb4
workaround "'PKOnlyObject' object has no attribute" error
n2ygk 0880575
add new Course and Term models to reproduce "'PKOnlyObject' object ha…
n2ygk a948813
use RelatedMixin.override_pk_only_optimization=True to prevent Attrib…
n2ygk 8c78bc7
default override_pk_only_optimization True
n2ygk d645f81
tox, flake8, isort, make test exception a passing test
n2ygk 5dc8e45
Merge remote-tracking branch 'upstream/master' into related_disable_p…
n2ygk f02c7c4
Merge remote-tracking branch 'upstream/master' into related_disable_p…
n2ygk d0debda
add drf39 and drfmaster tests (#498)
n2ygk 00fb5dc
Adjust to new flake8 3.6.0 version (#501)
sliverc b3eed32
Avoid patch on `RelationshipView` deleting relationship instance when…
Alig1493 860a096
Use pytest instead of py.test (#502)
sliverc a4d063f
Use pyupio to manage development dependencies (#503)
sliverc 56b5fd7
Initial Update (#506)
pyup-bot 1ce84f8
Adjust depreaction warning to state to move to JSON_API_FORMAT_FIELD_…
sliverc 7d14537
Update pytest from 3.9.2 to 3.9.3 (#508)
pyup-bot 274cb79
Update sphinx from 1.8.1 to 1.8.2 (#511)
pyup-bot 0f09a6e
Update pytest-factoryboy from 2.0.1 to 2.0.2 (#510)
pyup-bot 7cdcff7
Update pytest from 3.9.3 to 3.10.1 (#512)
pyup-bot 7ec8e42
Test support of DRF HyperlinkedIdentityField (#497)
Alig1493 4d7a655
workaround "'PKOnlyObject' object has no attribute" error
n2ygk a3ac0d2
add new Course and Term models to reproduce "'PKOnlyObject' object ha…
n2ygk 509edfa
use RelatedMixin.override_pk_only_optimization=True to prevent Attrib…
n2ygk 875b56b
default override_pk_only_optimization True
n2ygk 2262aa6
tox, flake8, isort, make test exception a passing test
n2ygk dc5d860
Merge branch 'related_disable_pk_only' of github.com:n2ygk/django-res…
n2ygk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Generated by Django 2.1 on 2018-10-13 09:33 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('example', '0005_auto_20180922_1508'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Course', | ||
fields=[ | ||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('effective_start_date', models.DateField(blank=True, default=None, null=True)), | ||
('effective_end_date', models.DateField(blank=True, default=None, null=True)), | ||
('last_mod_user_name', models.CharField(max_length=80)), | ||
('last_mod_date', models.DateField(auto_now=True)), | ||
('school_bulletin_prefix_code', models.CharField(max_length=10)), | ||
('suffix_two', models.CharField(max_length=2)), | ||
('subject_area_code', models.CharField(max_length=10)), | ||
('course_number', models.CharField(max_length=10)), | ||
('course_identifier', models.CharField(max_length=10, unique=True)), | ||
('course_name', models.CharField(max_length=80)), | ||
('course_description', models.TextField()), | ||
], | ||
options={ | ||
'ordering': ['course_number'], | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Term', | ||
fields=[ | ||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('effective_start_date', models.DateField(blank=True, default=None, null=True)), | ||
('effective_end_date', models.DateField(blank=True, default=None, null=True)), | ||
('last_mod_user_name', models.CharField(max_length=80)), | ||
('last_mod_date', models.DateField(auto_now=True)), | ||
('term_identifier', models.TextField(max_length=10)), | ||
('audit_permitted_code', models.PositiveIntegerField(blank=True, default=0)), | ||
('exam_credit_flag', models.BooleanField(default=True)), | ||
('course', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='course', to='example.Course')), | ||
], | ||
options={ | ||
'ordering': ['term_identifier'], | ||
}, | ||
), | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sliverc here's the test case that reproduces/fixes the bug. I made two new models and put sample data in drf_example as well so you can play around with this in dev as well as reproduce with test code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK good. I will have a look but I am not sure when I will get to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank-you. Some of these blames may help understand it:
I suppose just having
ResourceRelatedField.use_pk_only_optimization()
return False as was done forPolymorphicResourceRelatedField
would do the trick, but I don't understand exactly when the pk_only optimization should apply and when not.Maybe it should be False in
ResourceRelatedField
and addrelations.SkipDataMixin.use_ok_only_optimization()
to return True.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the above and
test_performance.PerformanceTestCase
fails.