Skip to content

Commit 9dc5832

Browse files
committed
Refactor return values
1 parent c37feea commit 9dc5832

File tree

2 files changed

+118
-112
lines changed

2 files changed

+118
-112
lines changed

singlestoredb/functions/ext/asgi.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,20 +306,14 @@ async def do_func( # type: ignore
306306
colspec.append((x['name'], rowdat_1_type_map[dtype]))
307307
info['colspec'] = colspec
308308

309-
def parse_return_type(s: str) -> List[str]:
310-
if s.startswith('tuple['):
311-
return s[6:-1].split(',')
312-
if s.startswith('array[tuple['):
313-
return s[12:-2].split(',')
314-
return [s]
315-
316309
# Setup return type
317310
returns = []
318-
for x in parse_return_type(sig['returns']['dtype']):
319-
dtype = x.replace('?', '')
311+
for x in sig['returns']:
312+
dtype = x['dtype'].replace('?', '')
320313
if dtype not in rowdat_1_type_map:
321314
raise TypeError(f'no data type mapping for {dtype}')
322-
returns.append(rowdat_1_type_map[dtype])
315+
print(x['name'], dtype)
316+
returns.append((x['name'], rowdat_1_type_map[dtype]))
323317
info['returns'] = returns
324318

325319
return do_func, info
@@ -665,7 +659,9 @@ async def __call__(
665659
func_info['colspec'], b''.join(data),
666660
),
667661
)
668-
body = output_handler['dump'](func_info['returns'], *out) # type: ignore
662+
body = output_handler['dump'](
663+
[x[1] for x in func_info['returns']], *out, # type: ignore
664+
)
669665

670666
await send(output_handler['response'])
671667

@@ -682,6 +678,7 @@ async def __call__(
682678
endpoint_info['signature'],
683679
url=self.url or reflected_url,
684680
data_format=self.data_format,
681+
function_type=endpoint_info['function_type'],
685682
),
686683
)
687684
body = '\n'.join(syntax).encode('utf-8')
@@ -775,6 +772,7 @@ def show_create_functions(
775772
app_mode=self.app_mode,
776773
replace=replace,
777774
link=link or None,
775+
function_type=endpoint_info['function_type'],
778776
),
779777
)
780778

0 commit comments

Comments
 (0)