(
model: string,
query: SelectQueryBuilder<any, any, any>,
selectOrInclude: Record<string, any>,
parentAlias: string,
)
| 325 | } |
| 326 | |
| 327 | private buildFieldSelection( |
| 328 | model: string, |
| 329 | query: SelectQueryBuilder<any, any, any>, |
| 330 | selectOrInclude: Record<string, any>, |
| 331 | parentAlias: string, |
| 332 | ) { |
| 333 | let result = query; |
| 334 | |
| 335 | for (const [field, payload] of Object.entries(selectOrInclude)) { |
| 336 | if (!payload) { |
| 337 | continue; |
| 338 | } |
| 339 | |
| 340 | if (field === '_count') { |
| 341 | result = this.buildCountSelection(result, model, parentAlias, payload); |
| 342 | continue; |
| 343 | } |
| 344 | |
| 345 | const fieldDef = this.requireField(model, field); |
| 346 | if (!fieldDef.relation) { |
| 347 | // scalar field |
| 348 | result = this.dialect.buildSelectField(result, model, parentAlias, field); |
| 349 | } else { |
| 350 | if (!fieldDef.array && !fieldDef.optional && payload.where) { |
| 351 | throw createInternalError(`Field "${field}" does not support filtering`, model); |
| 352 | } |
| 353 | if (fieldDef.originModel) { |
| 354 | result = this.dialect.buildRelationSelection( |
| 355 | result, |
| 356 | fieldDef.originModel, |
| 357 | field, |
| 358 | fieldDef.originModel, |
| 359 | payload, |
| 360 | ); |
| 361 | } else { |
| 362 | // regular relation |
| 363 | result = this.dialect.buildRelationSelection(result, model, field, parentAlias, payload); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | return result; |
| 369 | } |
| 370 | |
| 371 | private buildCountSelection( |
| 372 | query: SelectQueryBuilder<any, any, any>, |
nothing calls this directly
no test coverage detected