mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure parameter values are quoted when needed when editing roles. Fixes #4393
This commit is contained in:
@@ -17,6 +17,7 @@ Bug fixes
|
|||||||
*********
|
*********
|
||||||
|
|
||||||
| `Bug #4224 <https://redmine.postgresql.org/issues/4224>`_ - Prevent flickering of large tooltips on the Graphical EXPLAIN canvas.
|
| `Bug #4224 <https://redmine.postgresql.org/issues/4224>`_ - Prevent flickering of large tooltips on the Graphical EXPLAIN canvas.
|
||||||
|
| `Bug #4393 <https://redmine.postgresql.org/issues/4393>`_ - Ensure parameter values are quoted when needed when editing roles.
|
||||||
| `Bug #4395 <https://redmine.postgresql.org/issues/4395>`_ - EXPLAIN options should be Query Tool instance-specific.
|
| `Bug #4395 <https://redmine.postgresql.org/issues/4395>`_ - EXPLAIN options should be Query Tool instance-specific.
|
||||||
| `Bug #4429 <https://redmine.postgresql.org/issues/4429>`_ - Ensure drag/drop from the treeview works as expected on Firefox.
|
| `Bug #4429 <https://redmine.postgresql.org/issues/4429>`_ - Ensure drag/drop from the treeview works as expected on Firefox.
|
||||||
| `Bug #4437 <https://redmine.postgresql.org/issues/4437>`_ - Fix table icon issue when updating any existing field.
|
| `Bug #4437 <https://redmine.postgresql.org/issues/4437>`_ - Fix table icon issue when updating any existing field.
|
@@ -1,4 +1,4 @@
|
|||||||
SELECT att.attnum
|
SELECT att.attnum
|
||||||
FROM pg_attribute att
|
FROM pg_attribute att
|
||||||
WHERE att.attrelid = {{tid}}::oid
|
WHERE att.attrelid = {{tid}}::oid
|
||||||
AND att.attname = {{data.name|qtLiteral}}
|
AND att.attname = {{data.name|qtLiteral(True)}}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
{% macro APPLY(conn, database, role, param, value) -%}
|
{% macro APPLY(conn, database, role, param, value) -%}
|
||||||
ALTER {% if role %}ROLE {{ self.conn|qtIdent(role) }}{% if database %} IN DATABASE {{ conn|qtIdent(database) }}{% endif %}{% else %}DATABASE {{ conn|qtIdent(database) }}{% endif %}
|
ALTER {% if role %}ROLE {{ self.conn|qtIdent(role) }}{% if database %} IN DATABASE {{ conn|qtIdent(database) }}{% endif %}{% else %}DATABASE {{ conn|qtIdent(database) }}{% endif %}
|
||||||
|
|
||||||
SET {{ conn|qtIdent(param) }} TO {{ value }};
|
SET {{ conn|qtIdent(param) }} TO {{ value|qtLiteral }};
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
{% macro RESET(conn, database, role, param) -%}
|
{% macro RESET(conn, database, role, param) -%}
|
||||||
ALTER {% if role %}ROLE {{ self.conn|qtIdent(role) }}{% if database %} IN DATABASE {{ conn|qtIdent(database) }}{% endif %}{% else %}DATABASE {{ conn|qtIdent(database) }}{% endif %}
|
ALTER {% if role %}ROLE {{ self.conn|qtIdent(role) }}{% if database %} IN DATABASE {{ conn|qtIdent(database) }}{% endif %}{% else %}DATABASE {{ conn|qtIdent(database) }}{% endif %}
|
||||||
|
@@ -228,7 +228,7 @@ class Driver(BaseDriver):
|
|||||||
mgr.release()
|
mgr.release()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def qtLiteral(value):
|
def qtLiteral(value, forceQuote=False):
|
||||||
adapted = adapt(value)
|
adapted = adapt(value)
|
||||||
|
|
||||||
# Not all adapted objects have encoding
|
# Not all adapted objects have encoding
|
||||||
@@ -242,7 +242,14 @@ class Driver(BaseDriver):
|
|||||||
res = adapted.getquoted()
|
res = adapted.getquoted()
|
||||||
|
|
||||||
if isinstance(res, bytes):
|
if isinstance(res, bytes):
|
||||||
return res.decode('utf-8')
|
res = res.decode('utf-8')
|
||||||
|
|
||||||
|
if forceQuote is True:
|
||||||
|
# Convert the input to the string to use the startsWith(...)
|
||||||
|
res = str(res)
|
||||||
|
if not res.startswith("'"):
|
||||||
|
return "'" + res + "'"
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -343,6 +350,10 @@ class Driver(BaseDriver):
|
|||||||
value = None
|
value = None
|
||||||
|
|
||||||
for val in args:
|
for val in args:
|
||||||
|
# DataType doesn't have len function then convert it to string
|
||||||
|
if not hasattr(val, '__len__'):
|
||||||
|
val = str(val)
|
||||||
|
|
||||||
if len(val) == 0:
|
if len(val) == 0:
|
||||||
continue
|
continue
|
||||||
if hasattr(str, 'decode') and not isinstance(val, unicode):
|
if hasattr(str, 'decode') and not isinstance(val, unicode):
|
||||||
@@ -354,7 +365,7 @@ class Driver(BaseDriver):
|
|||||||
val = str(val).decode('utf-8')
|
val = str(val).decode('utf-8')
|
||||||
value = val
|
value = val
|
||||||
|
|
||||||
if (Driver.needsQuoting(val, True)):
|
if Driver.needsQuoting(val, True):
|
||||||
value = value.replace("\"", "\"\"")
|
value = value.replace("\"", "\"\"")
|
||||||
value = "\"" + value + "\""
|
value = "\"" + value + "\""
|
||||||
|
|
||||||
@@ -372,6 +383,11 @@ class Driver(BaseDriver):
|
|||||||
for val in args:
|
for val in args:
|
||||||
if type(val) == list:
|
if type(val) == list:
|
||||||
return map(lambda w: Driver.qtIdent(conn, w), val)
|
return map(lambda w: Driver.qtIdent(conn, w), val)
|
||||||
|
|
||||||
|
# DataType doesn't have len function then convert it to string
|
||||||
|
if not hasattr(val, '__len__'):
|
||||||
|
val = str(val)
|
||||||
|
|
||||||
if hasattr(str, 'decode') and not isinstance(val, unicode):
|
if hasattr(str, 'decode') and not isinstance(val, unicode):
|
||||||
# Handling for python2
|
# Handling for python2
|
||||||
try:
|
try:
|
||||||
@@ -385,7 +401,7 @@ class Driver(BaseDriver):
|
|||||||
|
|
||||||
value = val
|
value = val
|
||||||
|
|
||||||
if (Driver.needsQuoting(val, False)):
|
if Driver.needsQuoting(val, False):
|
||||||
value = value.replace("\"", "\"\"")
|
value = value.replace("\"", "\"\"")
|
||||||
value = "\"" + value + "\""
|
value = "\"" + value + "\""
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user