Skip to content

Commit 6fd514b

Browse files
committed
On database: WIP: daily backup 2025-10-24
2 parents 21cb2d8 + e98b5a5 commit 6fd514b

3 files changed

Lines changed: 54 additions & 4 deletions

File tree

botocore/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def __init__(self, shape_name, shape_model, shape_resolver=None):
121121
"""
122122
self.name = shape_name
123123
self.type_name = shape_model['type']
124+
self.boxed = shape_model.get('box', False)
124125
self.documentation = shape_model.get('documentation', '')
125126
self._shape_model = shape_model
126127
if shape_resolver is None:

botocore/parsers.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ class ResponseParserError(Exception):
194194
pass
195195

196196

197+
def box_decorator(func):
198+
def handle_box(self, shape, value):
199+
if shape.boxed and value is None:
200+
return None
201+
return func(self, shape, value)
202+
return handle_box
203+
204+
197205
class ResponseParser:
198206
"""Base class for response parsing.
199207
@@ -340,10 +348,13 @@ def _do_modeled_error_parse(self, response, shape, parsed):
340348
f"{self.__class__.__name__}._do_modeled_error_parse"
341349
)
342350

351+
BOXABLE_PRIMITIVE_TYPES = ["long", "integer", "boolean"]
343352
def _parse_shape(self, shape, node):
344353
handler = getattr(
345354
self, f'_handle_{shape.type_name}', self._default_handle
346355
)
356+
if shape.type_name in self.BOXABLE_PRIMITIVE_TYPES and shape.boxed and node is None:
357+
return None
347358
return handler(shape, node)
348359

349360
def _handle_list(self, shape, node):
@@ -1331,10 +1342,7 @@ def _handle_boolean(self, shape, value):
13311342
return ensure_boolean(value)
13321343

13331344
def _handle_integer(self, shape, value):
1334-
if value is None:
1335-
return None
1336-
else:
1337-
return int(value)
1345+
return int(value)
13381346

13391347
def _handle_float(self, shape, value):
13401348
return float(value)

main_botocore.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import boto3
2+
import botocore
3+
import json
4+
5+
boto3.set_stream_logger('')
6+
7+
8+
rds_client = boto3.client('rds-data')
9+
10+
sql = '''
11+
select array[123::int4, null::int4, 456::int4];
12+
'''
13+
14+
recs = rds_client.execute_statement(
15+
secretArn = 'arn:aws:secretsmanager:us-east-1:135633386280:secret:rds!cluster-9237ce19-931d-48a6-9130-c1f7e4930a27-ZLZKOT',
16+
resourceArn = 'arn:aws:rds:us-east-1:135633386280:cluster:data-api-test',
17+
database = 'postgres',
18+
sql = sql
19+
)
20+
21+
print(f'{recs}')
22+
23+
24+
# TODO: Working below for comparison
25+
26+
# import boto3
27+
# boto3.set_stream_logger('')
28+
#
29+
# rds_client = boto3.client('rds-data')
30+
#
31+
# sql = 'select array[123::int4, 789::int4, 456::int4];'
32+
#
33+
# recs = rds_client.execute_statement(
34+
# secretArn = 'arn:aws:secretsmanager:us-east-1:135633386280:secret:rds!cluster-9237ce19-931d-48a6-9130-c1f7e4930a27-ZLZKOT',
35+
# resourceArn = 'arn:aws:rds:us-east-1:135633386280:cluster:data-api-test',
36+
# database = 'postgres',
37+
# sql = sql
38+
# )
39+
#
40+
# print(f'{recs}')
41+

0 commit comments

Comments
 (0)