Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ jobs:
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
database: [postgresql, postgis]

services:
postgres:
image: postgres
image: postgis/postgis:14-3.1
env:
POSTGRES_DB: debug_toolbar
POSTGRES_USER: debug_toolbar
Expand Down Expand Up @@ -133,7 +134,7 @@ jobs:
- name: Test with tox
run: tox
env:
DB_BACKEND: postgresql
DB_BACKEND: ${{ matrix.database }}
DB_HOST: localhost
DB_PORT: 5432

Expand Down
8 changes: 0 additions & 8 deletions debug_toolbar/panels/sql/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ def _decode(self, param):
def _record(self, method, sql, params):
start_time = time()
try:
if isinstance(params, list):

def strip_GeomFromEWKB(param):
if isinstance(param, str):
return param.lstrip("ST_GeomFromEWKB('\\x").rstrip("'::bytea)")
return param

params = [strip_GeomFromEWKB(param) for param in params]
return method(sql, params)
finally:
stop_time = time()
Expand Down
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Change log
Next version
------------

* Revert PR 1426 - Fixes issue with SQL parameters having leading and
trailing characters stripped away.

3.2.3 (2021-12-12)
------------------

Expand Down
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"tests",
]

USE_GIS = os.getenv("DB_BACKEND") in ("postgis",)
USE_GIS = os.getenv("DB_BACKEND") == "postgis"

if USE_GIS:
INSTALLED_APPS = ["django.contrib.gis"] + INSTALLED_APPS
Expand Down
25 changes: 0 additions & 25 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import json
import os
import re
import unittest

import django
import html5lib
from django.conf import settings
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.core import signing
from django.core.cache import cache
Expand All @@ -18,7 +16,6 @@
from debug_toolbar.forms import SignedDataForm
from debug_toolbar.middleware import DebugToolbarMiddleware, show_toolbar
from debug_toolbar.panels import Panel
from debug_toolbar.panels.sql.forms import SQLSelectForm
from debug_toolbar.toolbar import DebugToolbar

from .base import BaseTestCase, IntegrationTestCase
Expand Down Expand Up @@ -310,28 +307,6 @@ def test_sql_explain_checks_show_toolbar(self):
)
self.assertEqual(response.status_code, 404)

@unittest.skipUnless(settings.USE_GIS, "Test only valid with gis support")
def test_sql_explain_gis(self):
from django.contrib.gis.geos import GEOSGeometry

from .models import Location

db_table = Location._meta.db_table

url = "/__debug__/sql_explain/"
geom = GEOSGeometry("POLYGON((0 0, 0 1, 1 1, 0 0))")
data = {
"sql": f'SELECT "{db_table}"."point" FROM "{db_table}" WHERE "{db_table}"."point" @ {geom.hex} LIMIT 1',
"raw_sql": f'SELECT "{db_table}"."point" FROM "{db_table}" WHERE "{db_table}"."point" @ %s LIMIT 1',
"params": json.dumps([geom.hex]),
"alias": "default",
"duration": "0",
}
data["hash"] = SQLSelectForm().make_hash(data)

response = self.client.post(url, data=data)
self.assertEqual(response.status_code, 200)

@unittest.skipUnless(
connection.vendor == "postgresql", "Test valid only on PostgreSQL"
)
Expand Down
6 changes: 6 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ setenv =
DB_BACKEND = postgresql
DB_PORT = {env:DB_PORT:5432}

[testenv:py{36,37,38,39,310}-dj{22,31,32,40,main}-postgis]
setenv =
{[testenv]setenv}
DB_BACKEND = postgis
DB_PORT = {env:DB_PORT:5432}

[testenv:py{36,37,38,39,310}-dj{22,31,32,40,main}-mysql]
setenv =
{[testenv]setenv}
Expand Down