Skip to content

Commit

Permalink
Drop Python 3.8 support, add Python 3.13 support. Add Postgres17 supp…
Browse files Browse the repository at this point in the history
…ort (#175)

* Initialize template from version 06d8661abae75a01f1d483bf16cf67f20972e9a0

* Update template to version 072543e27d8b506a6628f7793798609c62d6a8ae

* Update version and release notes

* Turn off jit to fix pg17 tests

* Formatting fix
  • Loading branch information
wesleykendall authored Nov 1, 2024
1 parent d590ccd commit 6f1b3a5
Show file tree
Hide file tree
Showing 15 changed files with 1,269 additions and 474 deletions.
15 changes: 7 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ orbs:
python:
working_directory: /code
docker:
- image: opus10/circleci-python-library:2024-04-17
- image: opus10/circleci-python-library:2024-10-26
environment:
# Ensure makefile commands are not wrapped in "docker compose run"
EXEC_WRAPPER: ''
Expand All @@ -25,11 +25,11 @@ orbs:
steps:
- checkout
- restore_cache:
key: v4-{{ checksum "poetry.lock" }}
key: v5-{{ checksum "poetry.lock" }}
- run: make dependencies
- run: make full-test-suite
- save_cache:
key: v4-{{ checksum "poetry.lock" }}
key: v5-{{ checksum "poetry.lock" }}
paths:
- /home/circleci/.cache/pypoetry/
- /code/.venv
Expand All @@ -46,7 +46,7 @@ jobs:
test_pg_max:
executor:
name: opus10/python
pg_version: "16.4"
pg_version: "17.0"
steps:
- opus10/test

Expand All @@ -55,7 +55,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: v4-{{ checksum "poetry.lock" }}
key: v5-{{ checksum "poetry.lock" }}
- run: make dependencies
- run: make lint

Expand All @@ -64,7 +64,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: v4-{{ checksum "poetry.lock" }}
key: v5-{{ checksum "poetry.lock" }}
- run: make dependencies
- run: make type-check || true

Expand All @@ -73,9 +73,8 @@ jobs:
steps:
- checkout
- run: ssh-add -D
- run: echo "${GITHUB_DEVOPS_PRIVATE_SSH_KEY_BASE64}" | base64 --decode | ssh-add - > /dev/null
- restore_cache:
key: v4-{{ checksum "poetry.lock" }}
key: v5-{{ checksum "poetry.lock" }}
- run: make dependencies
- run: poetry run python devops.py deploy

Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.9"
mkdocs:
configuration: mkdocs.yml
fail_on_warning: false
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 3.5.0 (2024-11-01)

### Features

- Optimized `Events` diff queries by ~100x via a subquery instead of `LAG` windows by [@lokhman](https://github.com/lokhman) in [#173](https://github.com/Opus10/django-pghistory/pull/173).
- Optimized object-level `Events` queries in the django admin by avoiding `UNION` queries by [@lokhman](https://github.com/lokhman) in [#174](https://github.com/Opus10/django-pghistory/pull/174).

### Changes

- Added Python 3.13 support, dropped Python 3.8. Added Postgres17 support by [@wesleykendall](https://github.com/wesleykendall) in [#175](https://github.com/Opus10/django-pghistory/pull/175).

## 3.4.4 (2024-09-27)

#### Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Above we printed the history of `int_field`. We also printed `pgh_obj`, which re

## Compatibility

`django-pghistory` is compatible with Python 3.8 - 3.12, Django 4.2 - 5.1, Psycopg 2 - 3, and Postgres 13 - 16.
`django-pghistory` is compatible with Python 3.9 - 3.13, Django 4.2 - 5.1, Psycopg 2 - 3, and Postgres 13 - 17.

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Above we printed the history of `int_field`. We also printed `pgh_obj`, which re

## Compatibility

`django-pghistory` is compatible with Python 3.8 - 3.12, Django 4.2 - 5.1, Psycopg 2 - 3, and Postgres 13 - 16.
`django-pghistory` is compatible with Python 3.9 - 3.13, Django 4.2 - 5.1, Psycopg 2 - 3, and Postgres 13 - 17.

## Next Steps

Expand Down
220 changes: 122 additions & 98 deletions docs/requirements.txt

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: django-pghistory
channels:
- conda-forge
dependencies:
- python==3.12.0
- poetry==1.6.1
- pip==23.2.1
- postgresql==16.0
- python==3.13.0
- poetry==1.8.4
- pip==24.2
- postgresql==17.0
variables:
DATABASE_URL: "postgres://postgres@localhost:5432/pghistory_local"
EXEC_WRAPPER: ""
2 changes: 1 addition & 1 deletion footing.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_extensions:
- jinja2_time.TimeExtension
_template: [email protected]:Opus10/public-django-app-template.git
_version: 06d8661abae75a01f1d483bf16cf67f20972e9a0
_version: 072543e27d8b506a6628f7793798609c62d6a8ae
check_types_in_ci: 'False'
is_django: 'True'
module_name: pghistory
Expand Down
8 changes: 5 additions & 3 deletions pghistory/admin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.contrib.admin.views.main import ChangeList
from django.utils.encoding import force_str

from pghistory import config, core, models
from pghistory import config, core


def _get_model(model):
Expand Down Expand Up @@ -228,11 +228,13 @@ def get_list_filter(self, request):
return filters

def get_queryset(self, request):
from pghistory.models import EventsQuerySet

queryset = config.admin_queryset()
if isinstance(queryset, models.EventsQuerySet):
if isinstance(queryset, EventsQuerySet): # pragma: no branch
object_id = request.resolver_match.kwargs.get("object_id")
if object_id is not None:
target_model = _get_model(unquote(object_id).partition(":")[0])
if target_model:
if target_model: # pragma: no branch
queryset = queryset.across(target_model)
return queryset
17 changes: 10 additions & 7 deletions pghistory/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import bs4
import ddf
import django
import pytest
from django import urls

Expand Down Expand Up @@ -72,16 +71,20 @@ def test_events_page(authed_client, settings):

# Don't show events on unfiltered views
settings.PGHISTORY_ADMIN_ALL_EVENTS = False

resp = authed_client.get(url)
assert resp.status_code == 200
html = resp.content.decode("utf-8")
assert "0 events" in html

# View the admin for an individual event
first_snapshot = test_models.SnapshotModelSnapshot.objects.first()

if django.VERSION < (3, 1): # pragma: no cover
num_events = models.Events.objects.count()
assert f"{num_events} events" in html
else:
assert "0 events" in html
url = urls.reverse(
"admin:pghistory_events_change",
kwargs={"object_id": f"tests.SnapshotModelSnapshot:{first_snapshot.pk}"},
)
resp = authed_client.get(url)
assert resp.status_code == 200


@pytest.mark.django_db
Expand Down
8 changes: 6 additions & 2 deletions pghistory/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,9 @@ def test_events_references_no_obj_tracking_filters(mocker):
"id": sm2.id,
"int_field": 33,
},
"pgh_diff": None,
"pgh_diff": {
"fk_field_id": [user2.id, user1.id],
},
"pgh_label": "custom_snapshot_update",
"pgh_model": "tests.CustomSnapshotModel",
"pgh_obj_id": str(sm2.pk),
Expand Down Expand Up @@ -847,7 +849,9 @@ def test_events_references_no_obj_tracking_filters(mocker):
"id": sm2.id,
"int_field": 33,
},
"pgh_diff": None,
"pgh_diff": {
"fk_field_id": [user2.id, user1.id],
},
"pgh_label": "snapshot_update",
"pgh_model": "tests.SnapshotModelSnapshot",
"pgh_obj_id": str(sm2.pk),
Expand Down
Loading

0 comments on commit 6f1b3a5

Please sign in to comment.