Skip to content

Avoid stripping additional characters from GIS SQL params. #1544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,73 @@ jobs:
with:
name: Python ${{ matrix.python-version }}

postgis:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']

services:
postgres:
image: postgis/postgis:14-3.1
env:
POSTGRES_DB: debug_toolbar
POSTGRES_USER: debug_toolbar
POSTGRES_PASSWORD: debug_toolbar
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v2

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

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v1-

- name: Install enchant (only for docs)
run: |
sudo apt-get -qq update
sudo apt-get -y install enchant

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions

- name: Test with tox
run: tox
env:
DB_BACKEND: postgis
DB_HOST: localhost
DB_PORT: 5432

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}

sqlite:
runs-on: ubuntu-latest
strategy:
Expand Down
4 changes: 3 additions & 1 deletion debug_toolbar/panels/sql/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ def _record(self, method, sql, params):

def strip_GeomFromEWKB(param):
if isinstance(param, str):
return param.lstrip("ST_GeomFromEWKB('\\x").rstrip("'::bytea)")
return param.split("ST_GeomFromEWKB('\\x", maxsplit=1)[
0
].rsplit("'::bytea)", maxsplit=1)[0]
return param

params = [strip_GeomFromEWKB(param) for param in params]
Expand Down
5 changes: 5 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ databases)::
psql> CREATE DATABASE debug_toolbar;
psql> GRANT ALL PRIVILEGES ON DATABASE debug_toolbar to debug_toolbar;

If you're going to test the PostGIS integration locally the PostgreSQL user
will need to be a super user in order to create the extensions.

psql> ALTER USER debug_toolbar WITH SUPERUSER;

For MySQL/MariaDB in a ``mysql`` shell::

mysql> CREATE DATABASE debug_toolbar;
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