Repository: jazzband/django-debug-toolbar

Issue:
Some String Has Truncated Before Model Save In  Releases Version==3.2.3
#### I found some string was truncated in this function

```python
def strip_GeomFromEWKB(param):
    if isinstance(param, str):
        return param.lstrip("ST_GeomFromEWKB('\\x").rstrip("'::bytea)")
    return param
```

#### Related Pull Request

- https://github.com/jazzband/django-debug-toolbar/pull/1426

####  Minimally Reproducible Test Case

```python
In [8]: "botpy".lstrip("ST_GeomFromEWKB('\\x").rstrip("'::bytea)")
Out[8]: 'botp'

In [9]: "Botpy".lstrip("ST_GeomFromEWKB('\\x").rstrip("'::bytea)")
Out[9]: 'tp'
```


Discussion:
@TryReboot do you have an example of a query that is impacted by this?
@tim-schilling  For example , you want to save a  string  into  some django model,  if this string include "y" or "e",  this string was truncated then  save into database.  I don't know if anyone else has same problem.
It sounds like the issue is when the parameter is not for a GIS query and it's stripping these characters still. 

Resolving patch:
diff --git a/debug_toolbar/panels/sql/tracking.py b/debug_toolbar/panels/sql/tracking.py
--- a/debug_toolbar/panels/sql/tracking.py
+++ b/debug_toolbar/panels/sql/tracking.py
@@ -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()


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -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
@@ -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
 
diff --git a/tests/settings.py b/tests/settings.py
--- a/tests/settings.py
+++ b/tests/settings.py
@@ -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
diff --git a/tests/test_integration.py b/tests/test_integration.py
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -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
@@ -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
@@ -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"
     )