Skip to content

Commit

Permalink
Fix double EXPLAIN when calling explain on a queryset
Browse files Browse the repository at this point in the history
  • Loading branch information
stereodamage committed Feb 18, 2025
2 parents 0416234 + 0a84caa commit 98da0db
Show file tree
Hide file tree
Showing 62 changed files with 2,024 additions and 214 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.13

- name: Install dependencies
run: |
Expand Down
61 changes: 19 additions & 42 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,22 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
django-version: ['3.2', '4.0', '4.1', 'main']
postgres-version: ['11', '12']
mariadb-version: ['10.3', '10.4']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
django-version: ['4.2', '5.0', '5.1', 'main']
postgres-version: ['13', '17']
mariadb-version: ['10.6', '10.11', '11.4']
exclude:
# Django >=4.0 drops support for python 3.7 (https://docs.djangoproject.com/en/4.1/faq/install/)
- python-version: '3.7'
django-version: '4.0'
- python-version: '3.7'
django-version: '4.1'
- python-version: '3.7'
django-version: 'main'

# Django <=4.0 doesn't support python 3.11 (https://docs.djangoproject.com/en/4.1/faq/install/)
- python-version: '3.11'
django-version: '3.2'
- python-version: '3.11'
django-version: '4.0'
# Django 5.0 doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.0/faq/install/)
- python-version: '3.9'
django-version: '5.0'

# only test Django dev with PostgreSQL 12 and MariaDB 10.4
- django-version: '3.2'
postgres-version: '12'
- django-version: '3.2'
mariadb-version: '10.4'

- django-version: '4.0'
postgres-version: '12'
- django-version: '4.0'
mariadb-version: '10.4'
# Django 5.1 doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.1/faq/install/)
- python-version: '3.9'
django-version: '5.1'

- django-version: '4.1'
postgres-version: '12'
- django-version: '4.1'
mariadb-version: '10.4'

- django-version: 'main'
postgres-version: '11'
- django-version: 'main'
mariadb-version: '10.3'
# Django main doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.1/faq/install/)
- python-version: '3.9'
django-version: 'main'

services:
postgres:
Expand All @@ -70,28 +47,28 @@ jobs:
MYSQL_ROOT_PASSWORD: mysql
MYSQL_DATABASE: mysql
options: >-
--health-cmd "mysqladmin ping"
--health-cmd "mariadb-admin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
Expand All @@ -111,6 +88,6 @@ jobs:
DJANGO: ${{ matrix.django-version }}

- name: Upload coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
name: Python ${{ matrix.python-version }}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ project/media/
project/tmp/
.vscode/

# Vagrant
.vagrant

# Hardlinks
/django_silky/silk

Expand Down
24 changes: 12 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.4.0'
rev: 'v5.0.0'
hooks:
- id: check-merge-conflict
- repo: https://github.com/hadialqattan/pycln
rev: v2.1.3
rev: v2.5.0
hooks:
- id: pycln
args: ['--all']
- repo: https://github.com/asottile/yesqa
rev: v1.4.0
rev: v1.5.0
hooks:
- id: yesqa
- repo: https://github.com/pycqa/isort
rev: '5.12.0'
rev: '5.13.2'
hooks:
- id: isort
args: ['--profile', 'black']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.4.0'
rev: 'v5.0.0'
hooks:
- id: end-of-file-fixer
exclude: >-
Expand Down Expand Up @@ -47,21 +47,21 @@ repos:
- id: detect-private-key
exclude: ^examples|(?:tests/ssl)/
- repo: https://github.com/asottile/pyupgrade
rev: 'v3.3.1'
rev: 'v3.19.1'
hooks:
- id: pyupgrade
args: ['--py37-plus', '--keep-mock']
args: ['--keep-mock']
- repo: https://github.com/adamchainz/django-upgrade
rev: '1.13.0'
rev: '1.22.2'
hooks:
- id: django-upgrade
args: [--target-version, '3.2']
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: 'v2.0.1'
args: [--target-version, '4.2']
- repo: https://github.com/hhatto/autopep8
rev: 'v2.3.2'
hooks:
- id: autopep8
- repo: https://github.com/PyCQA/flake8
rev: '6.0.0'
rev: '7.1.1'
hooks:
- id: flake8
exclude: '^docs/'
Expand Down
132 changes: 131 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,136 @@
# Change Log
## Unreleased

## [5.3.2](https://github.com/jazzband/django-silk/tree/5.3.2) (2024-12-05)
:release-by: Albert Wang (@albertyw)
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.3.1..5.3.2)

**Fixes:**

- Fix missing image from jQuery UI 1.13.2 (#757) @Tatsh

**Maintenance and Cleanup:**

- Adds updated documentation on middleware ordering (#758) @SoyJoseC
- Updated python dependencies (#761, #760) @albertyw


## [5.3.1](https://github.com/jazzband/django-silk/tree/5.3.1) (2024-11-08)
:release-by: Albert Wang (@albertyw)
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.3.0..5.3.1)

**Fixes:**

- Fix missing jQuery UI images (#754) @Tatsh
- Fix swallowing exceptions when processing response in silk middleware (#753) @albertyw


## [5.3.0](https://github.com/jazzband/django-silk/tree/5.3.0) (2024-10-25)
:release-by: Albert Wang (@albertyw)
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.2.0..5.3.0)

**Note: this release removes support for Django 3.2 and Python 3.8**

**Features/Enhancements:**

- Support python 3.13 (#747)

**Fixes:**

- Upgrade jQuery-UI to 1.13.2 to fix XSS vulnerability (#742)

**Maintenance and Cleanup:**

- Remove Django 3.2 support (#736)
- Drop support for python 3.8 (#749)
- Update python dependencies (#748)


## [5.2.0](https://github.com/jazzband/django-silk/tree/5.2.0) (2024-08-17)
:release-by: Albert Wang (@albertyw)
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.1.0..5.2.0)

**Features/Enhancements:**

- Support Django 5.1 (#734, #732) @albertyw

**Fixes:**

- Fix when Session, Authentication or Message middleware are not present (#667) @mgaligniana
- Update 'tables_involved' property to include tables from UPDATE operation (#717) @emregeldegul
- Fix double-escaping of the curl and Python example code (#709) @SpecLad
- Correct units in profiling and requests pages (#725) @ka28kumar

**Maintenance and Cleanup:**

- Update python dependencies (#733) @albertyw
- Refactor SQL query time calculation to use Django aggregation (#720) @beltagymohamed
- Fix test failures on Windows (#707) @SpecLad
- Update workflow actions (#700) @albertyw
- Update test matrix to latest version of django, postgres, and mariadb #701) @albertyw


## [5.1.0](https://github.com/jazzband/django-silk/tree/5.1.0) (2023-12-30)
:release-by: Albert Wang (@albertyw)
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.0.4..5.1.0)

**Upgrading:**

This release includes [Fix deprecation warning for get_storage_class #669](https://github.com/jazzband/django-silk/pull/669)
which deprecates `SILKY_STORAGE_CLASS`. Users should instead use the Django
`STORAGES` configuration. See [README](https://github.com/albertyw/django-silk/blob/master/README.md#profiling)
and [Django documentation](https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-STORAGES)
for more information.

Also, for python 3.12, the `cProfile` stdlib library cannot be enabled multiple times concurrently.
Silk will therefore skip profiling if another profile is already enabled.


**Features/Enhancements:**

- Allow option to delete profiles (#652) @viralj

**Fixes:**

- Gracefully error out when there are concurrent profilers (#692) @albertyw
- Always disable cProfile as part of cleanup (#699) @albertyw
- Fix when Session, Authentication or Message middlewares are not present (#667) @mgaligniana

**Maintenance and Cleanup:**

- Fix deprecation warning for get_storage_class (#669) @albertyw
- Support Django 4.2 (#685) @albertyw
- Support python 3.12 (#683) @albertyw
- Support Django 5 (#686) @albertyw
- Remove deprecated datetime.timezone.utc (#687) @albertyw
- Derive version from importlib (#697) @robinchow

**Dependencies:**

- Update python dependencies (#693) @albertyw


## [5.0.4](https://github.com/jazzband/django-silk/tree/5.0.4) (2023-09-17)
:release-by: Albert Wang (@albertyw)
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.0.3..5.0.4)

**Features/Enhancements:**

- Handle case-insensitive sensitive headers (#674) @shtimn
- Add a "pagetitle" block to Silky templates (#661) @vsajip
- Allow to generate more informative profile file name (#638) @k4rl85

**Maintenance and Cleanup:**

- Remove unsupported versions of Django and Python (#668) @albertyw
- Outsource all inline scripts and styles (#635) @sgelis
- Remove support for looking up headers on django &lt;3.2 (#643) @albertyw

**Dependencies:**

- Update python dependencies (#677) @albertyw


## [5.0.3](https://github.com/jazzband/django-silk/tree/5.0.3) (2023-01-12)
:release-by: Albert Wang (@albertyw)
[Full Changelog](https://github.com/jazzband/django-silk/compare/5.0.2..5.0.3)
Expand Down Expand Up @@ -134,7 +264,7 @@
- Add query execution plan to sql_detail (#452)
- Add Python 3.9 compatibility (#404)
- Replace re_path with path
- Fix transaction error for mysql
- Fix transaction error for mysql
- parse query when count joins to match only Keyword
- fix: DB connection to ClearDB when multiple databases
- fix: DataCollector sql_queries model not found on filter(request=self.request)
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Silk is a live profiling and inspection tool for the Django framework. Silk inte

Silk has been tested with:

* Django: 3.2, 4.0, 4.1
* Python: 3.7, 3.8, 3.9, 3.10, 3.11
* Django: 4.2, 5.0, 5.1
* Python: 3.9, 3.10, 3.11, 3.12, 3.13

## Installation

Expand All @@ -56,7 +56,7 @@ INSTALLED_APPS = (
)
```

**Note:** The middleware placement is sensitive. If the middleware before `silk.middleware.SilkyMiddleware` returns from `process_request` then `SilkyMiddleware` will never get the chance to execute. Therefore you must ensure that any middleware placed before never returns anything from `process_request`. See the [django docs](https://docs.djangoproject.com/en/dev/topics/http/middleware/#process-request) for more information on this.
**Note:** The order of middleware is sensitive. If any middleware placed before `silk.middleware.SilkyMiddleware` returns a response without invoking its `get_response`, the `SilkyMiddleware` won’t run. To avoid this, ensure that middleware preceding `SilkyMiddleware` does not bypass or return a response without calling its `get_response`. For further details, check out the [Django documentation](https://docs.djangoproject.com/en/dev/topics/http/middleware/#middleware-order-and-layering).

**Note:** If you are using `django.middleware.gzip.GZipMiddleware`, place that **before** `silk.middleware.SilkyMiddleware`, otherwise you will get an encoding error.

Expand Down Expand Up @@ -150,7 +150,7 @@ Before diving into the stack trace to figure out where this request is coming fr

### Profiling

Turn on the SILKY_PYTHON_PROFILER setting to use Python's built-in cProfile profiler. Each request will be separately profiled and the profiler's output will be available on the request's Profiling page in the Silk UI.
Turn on the SILKY_PYTHON_PROFILER setting to use Python's built-in `cProfile` profiler. Each request will be separately profiled and the profiler's output will be available on the request's Profiling page in the Silk UI. Note that as of Python 3.12, `cProfile` cannot run concurrently so [django-silk under Python 3.12 and later will not profile if another profile is running](https://github.com/jazzband/django-silk/pull/692) (even its own profiler in another thread).

```python
SILKY_PYTHON_PROFILER = True
Expand All @@ -170,6 +170,16 @@ When enabled, a graph visualisation generated using [gprof2dot](https://github.c
A custom storage class can be used for the saved generated binary `.prof` files:

```python
# For Django >= 4.2 and Django-Silk >= 5.1.0:
# See https://docs.djangoproject.com/en/5.0/ref/settings/#std-setting-STORAGES
STORAGES = {
'SILKY_STORAGE': {
'BACKEND': 'path.to.StorageClass',
},
# ...
}

# For Django < 4.2 or Django-Silk < 5.1.0
SILKY_STORAGE_CLASS = 'path.to.StorageClass'
```

Expand Down
8 changes: 0 additions & 8 deletions Vagrantfile

This file was deleted.

4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ Features
Requirements
------------

* Django: 3.2, 4.0, 4.1
* Python: 3.7, 3.8, 3.9, 3.10
* Django: 4.2, 5.0, 5.1
* Python: 3.9, 3.10, 3.11, 3.12, 3.13
Loading

0 comments on commit 98da0db

Please sign in to comment.