Skip to content

Commit

Permalink
Add support for binary types (#89)
Browse files Browse the repository at this point in the history
* Add support for binary types

Fixes #88

* Ignore coverage

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
  • Loading branch information
roganov and koxudaxi committed Mar 5, 2021
1 parent 2c58206 commit c737eec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions local_data_api/resources/jdbc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def get_filed_from_jdbc_type(self, value: Any, jdbc_type: Optional[int]) -> Fiel
elif type_ in BOOLEAN:
return Field(booleanValue=value)
elif type_ in BLOB:
if isinstance(value, str): # pragma: no cover
value = value.encode()
return Field(blobValue=b64encode(value))

return self.get_field_from_value(value)
Expand Down
18 changes: 18 additions & 0 deletions scripts/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ function test {
--include-result-metadata \
--sql 'SELECT 1 > 0 AS value' \
| jq -e '.records[0][0].booleanValue == true'

aws rds-data execute-statement \
--endpoint-url 'http://localhost:8080' \
--database 'test' \
--resource-arn $RDS_DATA_API_CLIENT_RESOURCE_ARN \
--secret-arn $RDS_DATA_API_CLIENT_SECRETARN \
--include-result-metadata \
--sql $'SELECT \'hello\'::bytea as value' \
| jq -e '.records[0][0].blobValue == "aGVsbG8="'
fi

# select boolean (mysql)
Expand All @@ -72,6 +81,15 @@ function test {
--include-result-metadata \
--sql 'SELECT 1 > 0 AS value' \
| jq -e '.records[0][0].longValue == 1'

aws rds-data execute-statement \
--endpoint-url 'http://localhost:8080' \
--database 'test' \
--resource-arn $RDS_DATA_API_CLIENT_RESOURCE_ARN \
--secret-arn $RDS_DATA_API_CLIENT_SECRETARN \
--include-result-metadata \
--sql $'SELECT BINARY \'hello\' as value' \
| jq -e '.records[0][0].blobValue == "aGVsbG8="'
fi

aws rds-data execute-statement \
Expand Down

0 comments on commit c737eec

Please sign in to comment.