Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pgAdmin argument formats can't be mixed

Background

  • Ubuntu 18.04
  • Postgresql 11.2 in Docker
  • pgAdmin4 3.5

Have a column named alias with type character varying[](64). Values have already been set on some rows before using psycopg2. Everything was alright then.

SQL = 'UPDATE public."mytable" SET alias=%s WHERE id=%s'
query = cursor.mogrify(SQL, ([values] , id))
cursor.execute(query)
conn.commit()

Recently, when I want to add more value using pgAdmin GUI as shown in the first figure, the error in the second figure happens, which says Argument formats can't be mixed:

enter image description here

enter image description here

Well, it turns out if insert the values using script such as psql or query tool in pgAdmin, the error does not happen, i.e., it only happens if using GUI of pgAdmin.

Example script:

UPDATE public."mytable" SET alias='{a, b}' WHERE id='myid'

But as the GUI is much easier to modify values, so really want to figure it out. Any idea?

like image 737
Steven Luo Avatar asked May 13 '19 10:05

Steven Luo


1 Answers

It's a bug in pgAdmin 4.17.

It looks like it happens whenever you edit a char(n)[] or varchar(n)[] cell in a table (although char[] and varchar[] are unaffected).

It should be fixed in 4.18.

In the meantime, you can fix it yourself without much trouble. The pgAdmin4 backend is written in Python, so there's no need to rebuild anything; you can just dive in and change the source.

Find the directory where pgAdmin4 is installed, and open web/pgadmin/tools/sqleditor/__init__.py in an editor. Find the line:

typname = '%s(%s)[]'.format(

...and change it to:

typname = '{}({})[]'.format(

You'll need to restart the pgAdmin4 service for the change to take effect.

like image 57
Nick Barnes Avatar answered Nov 10 '22 15:11

Nick Barnes