From 01fd7dbec8e73ac213508939e449d76ea851b12a Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Wed, 22 Nov 2023 15:47:57 +0100
Subject: [PATCH] Pamhyr2: Fix some type compare.

---
 src/Model/Tools/PamhyrDB.py |  4 ++--
 src/tools.py                | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/Model/Tools/PamhyrDB.py b/src/Model/Tools/PamhyrDB.py
index bfea282e..8ee134fc 100644
--- a/src/Model/Tools/PamhyrDB.py
+++ b/src/Model/Tools/PamhyrDB.py
@@ -115,9 +115,9 @@ class SQLSubModel(object):
 
     def _db_format(self, value):
         # Replace ''' by '&#39;' to preserve SQL injection
-        if value is str:
+        if type(value) is str:
             value = value.replace("'", "&#39;")
-        elif value is bool:
+        elif type(value) is bool:
             value = 'TRUE' if value else 'FALSE'
         return value
 
diff --git a/src/tools.py b/src/tools.py
index 657752e0..b6f78857 100644
--- a/src/tools.py
+++ b/src/tools.py
@@ -297,7 +297,7 @@ class SQL(object):
     def _fetch_tuple(self, tup):
         res = []
         for v in tup:
-            if v is str:
+            if type(v) is str:
                 v = self._fetch_string(v)
             res.append(v)
 
@@ -306,9 +306,9 @@ class SQL(object):
     def _fetch_list(self, lst):
         res = []
         for v in lst:
-            if v is str:
+            if type(v) is str:
                 v = self._fetch_string(v)
-            elif v is tuple:
+            elif type(v) is tuple:
                 v = self._fetch_tuple(v)
             res.append(v)
 
@@ -321,9 +321,9 @@ class SQL(object):
             value = res.fetchall()
         res = value
 
-        if value is list:
+        if type(value) is list:
             res = self._fetch_list(value)
-        elif value is tuple:
+        elif type(value) is tuple:
             res = self._fetch_tuple(value)
 
         return res
-- 
GitLab