@@ -189,13 +189,19 @@ endpoints.forEach(function(endpoint) {
189189 // filter out aggregated_queries for a while (see #17)
190190 return
191191 }
192+
193+ // define before "if", to make it available later
194+ let dataType
195+ if (method .name !== ' delete' ) {
196+ const dto = query2dto (sqlParser, method)
197+ // LATER: do we really need signature and cache?
198+ dataType = obtainDtoName (dto)
199+ }
200+
192201 const params = extractParamsFromQuery (method .query )
193202 const hasGetOne = method .name === ' get'
194203 const hasGetMany = method .name === ' get_list'
195204 if (hasGetOne || hasGetMany) {
196- const dto = query2dto (sqlParser, method)
197- // LATER: do we really need signature and cache?
198- const dataType = obtainDtoName (dto)
199205 const resultVariableDeclaration = hasGetMany
200206 ? ` result := []${ dataType} \{\} `
201207 : ` var result ${ dataType} `
@@ -238,9 +244,6 @@ endpoints.forEach(function(endpoint) {
238244< %
239245 }
240246 if (method .name === ' post' ) {
241- const dto = query2dto (sqlParser, method)
242- // LATER: do we really need signature and cache?
243- const dataType = obtainDtoName (dto)
244247% >
245248 r .Post (" <%- path %>" , func (w http .ResponseWriter , r * http .Request ) {
246249 var body < %- dataType % >
@@ -264,9 +267,6 @@ endpoints.forEach(function(endpoint) {
264267< %
265268 }
266269 if (method .name === ' put' ) {
267- const dto = query2dto (sqlParser, method)
268- // LATER: do we really need signature and cache?
269- const dataType = obtainDtoName (dto)
270270% >
271271 r .Put (" <%- path %>" , func (w http .ResponseWriter , r * http .Request ) {
272272 var body < %- dataType % >
0 commit comments