mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-27 11:10:19 -06:00
Generic function qtLiteral was not adapting values properly when they contain non ascii characters. Fixes #2305
This commit is contained in:
parent
4ba9269a88
commit
9acf340400
@ -1828,21 +1828,20 @@ class Driver(BaseDriver):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def qtLiteral(value):
|
def qtLiteral(value):
|
||||||
try:
|
adapted = adapt(value)
|
||||||
res = adapt(value).getquoted()
|
|
||||||
except UnicodeEncodeError:
|
# Not all adapted objects have encoding
|
||||||
# We will handle special characters with utf8 encoding
|
# e.g.
|
||||||
adapted = adapt(value)
|
# psycopg2.extensions.BOOLEAN
|
||||||
|
# psycopg2.extensions.FLOAT
|
||||||
|
# psycopg2.extensions.INTEGER
|
||||||
|
# etc...
|
||||||
|
if hasattr(adapted, 'encoding'):
|
||||||
adapted.encoding = 'utf8'
|
adapted.encoding = 'utf8'
|
||||||
res = adapted.getquoted()
|
res = adapted.getquoted()
|
||||||
|
|
||||||
# Returns in bytes, we need to convert it in string
|
|
||||||
if isinstance(res, bytes):
|
if isinstance(res, bytes):
|
||||||
try:
|
return res.decode('utf-8')
|
||||||
res = res.decode()
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
res = res.decode('utf-8')
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user