koxudaxi/local-data-api

Support PgArray

sdurban opened this issue · 2 comments

Describe the bug
When you try to get a postgresql array column like:

SELECT string_to_array('1, 2, 3, 4', ',');

App will crash with the error:

Exception: unsupported type <class 'jpype._jclass.org.postgresql.jdbc.PgArray'>: {1," 2"," 3"," 4"}

To Reproduce
In postgresql make a query like (engine configured as PostgreSQLJDBC).

POST http://127.0.0.1:8080/Execute
User-Agent: aws-sdk-nodejs/2.647.0 linux/v12.16.1 promise
Content-Type: application/json
{
"secretArn": "arn:aws:secretsmanager:us-east-1:123456789012㊙️dummy",
"resourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:dummy",
"sql": "SELECT string_to_array('1, 2, 3, 4', ',')",
"database": "test"
}

Expected behavior
App needs to return a string value {1, 2, 3, 4} like in this example from a real aurora data api:
image

In definition is a stringvalue.
image

About PostgresSQL Engine (No JDBC)
Making the query with python native connector returns a list:

unsupported type <class 'list'>: ['1', ' 2', ' 3', ' 4']

I think is kind of dangerous make a conversion from list to a schema like {1, 2, 3, 4}. Maybe it needs a refactor like conversions-per-type (JVM(PSQL/MYSQL) an non-JVM classes (PSQL and MYSQL separated)?

@sdurban

I think is kind of dangerous make a conversion from list to a schema like {1, 2, 3, 4}. Maybe it needs a refactor like conversions-per-type (JVM(PSQL/MYSQL) an non-JVM classes (PSQL and MYSQL separated)?

I agreed.
I will create issue for this refactoring.
But, I may not able to get time refactoring the logic on another project 😅

Thanks for the fast accept ;).