Skip to content

Commit

Permalink
Fix issue where response was an embedded json string
Browse files Browse the repository at this point in the history
  • Loading branch information
jbirddog committed Dec 22, 2023
1 parent dc01e63 commit 59901e1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/connector_postgres_v2/base_command.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from typing import Any

import psycopg2 # type: ignore
Expand Down Expand Up @@ -36,7 +35,7 @@ def _execute(self, sql: str, conn_str: str, handler: Any) -> ConnectorProxyRespo
conn.close()

command_response: CommandResponseDict = {
"body": json.dumps(command_response_body),
"body": command_response_body,
"mimetype": "application/json",
}
return_response: ConnectorProxyResponseDict = {
Expand Down Expand Up @@ -66,8 +65,8 @@ def handler(conn: Any, cursor: Any) -> None:
return self._execute(sql, conn_str, handler)

def fetchall(self, sql: str, conn_str: str, values: list) -> ConnectorProxyResponseDict:
def prep_results(results: dict) -> list:
return list(map(list, results))
def prep_results(results: list) -> list:
return [r[0][1:-1].replace('"', '').split(",") for r in results]
def handler(conn: Any, cursor: Any) -> list:
cursor.execute(sql, values)
return prep_results(cursor.fetchall())
Expand Down

0 comments on commit 59901e1

Please sign in to comment.