@@ -167,29 +167,29 @@ endpoints.forEach(function(endpoint) {
167
167
const argsFromQuery = method .query ? extractParamsFromQuery (method .query ).map (stipOurPrefixes) : []
168
168
const methodArgs = Array .from (new Set ([... argsFromPath, ... argsFromQuery, ' conn=Depends(db_connection)' ]))
169
169
170
- const queriesWithNames = []
171
- if (method .query ) {
172
- queriesWithNames .push ({ " result" : method .query })
173
- } else if (method .aggregated_queries ) {
174
- for (const [key , value ] of Object .entries (method .aggregated_queries )) {
175
- queriesWithNames .push ({ [key]: value })
176
- }
177
- }
170
+ if (hasGetOne || hasGetMany) {
178
171
179
- const queries = []
180
- queriesWithNames .forEach (queryWithName => {
181
- for (const [name , query ] of Object .entries (queryWithName)) {
182
- const sql = convertToPsycopgNamedArguments (formatQueryForPython (query, 20 ))
183
- const params = extractParamsFromQuery (query);
184
- const formattedParams = params .length > 0
185
- // [ "p.categoryId" ] => [ '"categoryId": categoryId' ]
186
- ? ' , {' + params .map (param => param .substring (2 )).map (param => ` "${ param} ": ${ param} ` ).join (' , ' ) + ' }'
187
- : ' '
188
- queries .push ({ [name]: { sql : sql, formattedParams: formattedParams }})
172
+ const queriesWithNames = []
173
+ if (method .query ) {
174
+ queriesWithNames .push ({ " result" : method .query })
175
+ } else if (method .aggregated_queries ) {
176
+ for (const [key , value ] of Object .entries (method .aggregated_queries )) {
177
+ queriesWithNames .push ({ [key]: value })
178
+ }
189
179
}
190
- })
191
180
192
- if (hasGetOne || hasGetMany) {
181
+ const queries = []
182
+ queriesWithNames .forEach (queryWithName => {
183
+ for (const [name , query ] of Object .entries (queryWithName)) {
184
+ const sql = convertToPsycopgNamedArguments (formatQueryForPython (query, 20 ))
185
+ const params = extractParamsFromQuery (query);
186
+ const formattedParams = params .length > 0
187
+ // [ "p.categoryId" ] => [ '"categoryId": categoryId' ]
188
+ ? ' , {' + params .map (param => param .substring (2 )).map (param => ` "${ param} ": ${ param} ` ).join (' , ' ) + ' }'
189
+ : ' '
190
+ queries .push ({ [name]: { sql : sql, formattedParams: formattedParams }})
191
+ }
192
+ })
193
193
% >
194
194
195
195
@router .get (' <%- path %>' )
0 commit comments