From 27d8d4a7def24d8316eb21c8671106f297455f55 Mon Sep 17 00:00:00 2001 From: Wes Kendall Date: Fri, 6 Sep 2024 20:31:48 -0500 Subject: [PATCH] Fix the default setting for related_query_name (#163) --- CHANGELOG.md | 6 + pghistory/config.py | 6 +- ...utofieldmodelevent_pgh_context_and_more.py | 344 ++++++++++++++++++ pyproject.toml | 2 +- 4 files changed, 354 insertions(+), 4 deletions(-) create mode 100644 pghistory/tests/migrations/0012_alter_bigautofieldmodelevent_pgh_context_and_more.py diff --git a/CHANGELOG.md b/CHANGELOG.md index a10fb46..830f32e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 3.4.1 (2024-09-06) + +#### Fixes + +- The `related_query_name` setting for tracked foreign keys had the default value mistakenly changed in v3.4.0. Fixed by [@wesleykendall](https://github.com/wesleykendall) in [#163](https://github.com/Opus10/django-pghistory/pull/163). + ## 3.4.0 (2024-09-02) #### Features diff --git a/pghistory/config.py b/pghistory/config.py index a26cc9d..fda0caa 100644 --- a/pghistory/config.py +++ b/pghistory/config.py @@ -425,7 +425,7 @@ def __init__( self, *, null: bool = True, - related_query_name: Union[str, constants.Unset, constants.Default] = constants.UNSET, + related_query_name: Union[str, constants.Unset, constants.Default] = constants.DEFAULT, **kwargs: Any, ): super().__init__(null=null, related_query_name=related_query_name, **kwargs) @@ -467,8 +467,8 @@ class ObjForeignKey(ForeignKey): def __init__( self, *, - related_name: Union[str, constants.Unset, constants.Default] = constants.UNSET, - related_query_name: Union[str, constants.Unset, constants.Default] = constants.UNSET, + related_name: Union[str, constants.Unset, constants.Default] = constants.DEFAULT, + related_query_name: Union[str, constants.Unset, constants.Default] = constants.DEFAULT, **kwargs, ): # Note: We will be changing the default object field to nullable with on_delete=SET_NULL diff --git a/pghistory/tests/migrations/0012_alter_bigautofieldmodelevent_pgh_context_and_more.py b/pghistory/tests/migrations/0012_alter_bigautofieldmodelevent_pgh_context_and_more.py new file mode 100644 index 0000000..edd3205 --- /dev/null +++ b/pghistory/tests/migrations/0012_alter_bigautofieldmodelevent_pgh_context_and_more.py @@ -0,0 +1,344 @@ +# Generated by Django 4.2.6 on 2024-09-07 01:19 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("pghistory", "0006_delete_aggregateevent"), + ( + "tests", + "0011_ignoreautofieldssnapshotmodelcreatedatupdatedatmycharfieldmyintfieldevent_and_more", + ), + ] + + operations = [ + migrations.AlterField( + model_name="bigautofieldmodelevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="bigautofieldmodelevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="events", + to="tests.bigautofieldmodel", + ), + ), + migrations.AlterField( + model_name="customeventmodel", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="custom_related_name", + to="tests.eventmodel", + ), + ), + migrations.AlterField( + model_name="customeventwithcontext", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="customeventwithcontext", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="tests.eventmodel", + ), + ), + migrations.AlterField( + model_name="custommodelevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="custommodelevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="events", + to="tests.custommodel", + ), + ), + migrations.AlterField( + model_name="custommodelsnapshot", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="custommodelsnapshot", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="snapshot", + to="tests.custommodel", + ), + ), + migrations.AlterField( + model_name="customsnapshotmodel", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="custom_related_name", + to="tests.snapshotmodel", + ), + ), + migrations.AlterField( + model_name="denormcontextevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="events", + to="tests.denormcontext", + ), + ), + migrations.AlterField( + model_name="denormcontexteventnoid", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="event_no_id", + to="tests.denormcontext", + ), + ), + migrations.AlterField( + model_name="eventmodelevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="eventmodelevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="events", + to="tests.eventmodel", + ), + ), + migrations.AlterField( + model_name="ignoreautofieldssnapshotmodelcreatedatupdatedatmycharfieldmyintfieldevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="ignoreautofieldssnapshotmodelcreatedatupdatedatmycharfieldmyintfieldevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="no_auto_fields_event", + to="tests.ignoreautofieldssnapshotmodel", + ), + ), + migrations.AlterField( + model_name="nopghobjevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="nopghobjsnapshot", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="snapshotimagefieldevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="snapshotimagefieldevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="events", + to="tests.snapshotimagefield", + ), + ), + migrations.AlterField( + model_name="snapshotmodeldtfieldevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="snapshotmodeldtfieldevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="dt_field_snapshot", + to="tests.snapshotmodel", + ), + ), + migrations.AlterField( + model_name="snapshotmodeldtfieldintfieldevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="snapshotmodeldtfieldintfieldevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="dt_field_int_field_snapshot", + to="tests.snapshotmodel", + ), + ), + migrations.AlterField( + model_name="snapshotmodelsnapshot", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="snapshotmodelsnapshot", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="snapshot", + to="tests.snapshotmodel", + ), + ), + migrations.AlterField( + model_name="snapshotuntrackedfield", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="snapshotuntrackedfield", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="untracked_field_event", + to="tests.ignoreautofieldssnapshotmodel", + ), + ), + migrations.AlterField( + model_name="uniqueconstraintmodelevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + migrations.AlterField( + model_name="uniqueconstraintmodelevent", + name="pgh_obj", + field=models.ForeignKey( + db_constraint=False, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="snapshot", + to="tests.uniqueconstraintmodel", + ), + ), + migrations.AlterField( + model_name="usergroupsevent", + name="pgh_context", + field=models.ForeignKey( + db_constraint=False, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + related_name="+", + to="pghistory.context", + ), + ), + ] diff --git a/pyproject.toml b/pyproject.toml index a06c2ab..25fb48d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ packages = [ exclude = [ "*/tests/" ] -version = "3.4.0" +version = "3.4.1" description = "History tracking for Django and Postgres" authors = ["Wes Kendall"] classifiers = [