@@ -166,6 +166,11 @@ function dtoInCache(dto) {
166
166
return dtoCache .hasOwnProperty (dto .signature )
167
167
}
168
168
169
+ function obtainDtoName (dto ) {
170
+ const cacheKey = dto ? dto .signature : null
171
+ return dtoInCache (dto) ? dtoCache[cacheKey] : dto .name
172
+ }
173
+
169
174
// Generate models
170
175
const verbs_with_dto = [ ' post' , ' put' ]
171
176
endpoints .forEach (function (endpoint ) {
@@ -263,8 +268,7 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
263
268
if (method .name === ' post' ) {
264
269
const dto = query2dto (sqlParser, method)
265
270
// LATER: do we really need signature and cache?
266
- const cacheKey = dto ? dto .signature : null
267
- const model = dtoInCache (dto) ? dtoCache[cacheKey] : dto .name
271
+ const model = obtainDtoName (dto)
268
272
269
273
const sql = convertToPsycopgNamedArguments (formatQueryForPython (method .query , 20 ))
270
274
const params = extractParamsFromQuery (method .query )
@@ -288,8 +292,7 @@ def <%- pythonMethodName %>(body: <%- model %>, conn=Depends(db_connection)):
288
292
// TODO: reduce duplication with POST
289
293
const dto = query2dto (sqlParser, method)
290
294
// LATER: do we really need signature and cache?
291
- const cacheKey = dto ? dto .signature : null
292
- const model = dtoInCache (dto) ? dtoCache[cacheKey] : dto .name
295
+ const model = obtainDtoName (dto)
293
296
294
297
const methodArgs = [ ` body: ${ model} ` , ... argsFromPath, ' conn=Depends(db_connection)' ]
295
298
0 commit comments