You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there is a reason to keep the conversion in ansible, I propose to change it from
deflist_to_pg_array(elem):
"""Convert the passed list to PostgreSQL array represented as a string. Args: elem (list): List that needs to be converted. Returns: elem (str): String representation of PostgreSQL array. """elem=str(elem).strip('[]')
elem='{'+elem+'}'returnelem
@betanummeric hello, thanks for reporting the issue!
I don't remember any reason to use the code instead of psycopg2 functionality (maybe who wrote it-probably me-just didn't know the better way). So let's try it?
Provided that it works and it's covered by CI, it'll be a good fix
The postgresql_query and postgresql_script modules use this code to transform a list in the arguments to an postgres array string: https://github.com/ansible-collections/community.postgresql/blob/2.3.2/plugins/module_utils/postgres.py#L387-L422
quoting issue
The current implementation doesn't work for a list of strings, because the single quotes from python become part of the array value:
results in
while I would expect something like
because single and double quotes are not the same in postgres:
ways to fix
psycopg2 knows how to convert python lists into postgres arrays: https://www.psycopg.org/docs/usage.html#adapt-list
I think we could just skip the conversion done in ansible and leave it to psycopg2.
If there is a reason to keep the conversion in ansible, I propose to change it from
to
The text was updated successfully, but these errors were encountered: