File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -150,25 +150,30 @@ function dto2model(dto) {
150
150
151
151
let globalDtoCounter = 0
152
152
const dtoCache = {}
153
+ const namedDtoCache = {}
153
154
154
155
// LATER: reduce duplication with routes.go.ejs
155
156
function cacheDto (dto ) {
156
- dtoCache[dto .signature ] = dto .name
157
+ if (dto .hasUserProvidedName ) {
158
+ namedDtoCache[dto .signature ] = dto .name
159
+ } else {
160
+ dtoCache[dto .signature ] = dto .name
161
+ }
157
162
return dto
158
163
}
159
164
160
165
// LATER: reduce duplication with routes.go.ejs
161
166
function dtoInCache (dto ) {
162
- // always prefer user specified name even when we have a similar DTO in cache
167
+ // always prefer user specified name even when we have a similar DTO in cache for generated names
163
168
if (dto .hasUserProvidedName ) {
164
- return false
169
+ return namedDtoCache . hasOwnProperty ( dto . signature )
165
170
}
166
171
return dtoCache .hasOwnProperty (dto .signature )
167
172
}
168
173
169
174
function obtainDtoName (dto ) {
170
- const cacheKey = dto ? dto .signature : null
171
- return dtoInCache (dto ) ? dtoCache [cacheKey] : dto .name
175
+ const cacheKey = dto .signature
176
+ return namedDtoCache . hasOwnProperty (cacheKey ) ? namedDtoCache [cacheKey] : dto .name
172
177
}
173
178
174
179
// Generate models
You can’t perform that action at this time.
0 commit comments