Skip to content

Commit

Permalink
Fix the default setting for related_query_name (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleykendall authored Sep 7, 2024
1 parent 0429ca5 commit 27d8d4a
Show file tree
Hide file tree
Showing 4 changed files with 354 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions pghistory/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 27d8d4a

Please sign in to comment.