(query: URLSearchParams)
| 121 | } |
| 122 | |
| 123 | get(query: URLSearchParams): IQuery { |
| 124 | const conditions: IQuery = this.parseSections(query); |
| 125 | const usedColumns: string[] = this.getUsedColumns(conditions); |
| 126 | const undefinedColumns = usedColumns.filter((columnName) => { |
| 127 | let currentModel: IModelService | undefined = this.model; |
| 128 | let realColumName = columnName; |
| 129 | if (columnName.includes(".")) { |
| 130 | const [table, splittedColumnName] = columnName.split("."); |
| 131 | currentModel = this.models.find( |
| 132 | (model) => model.instance.table === table, |
| 133 | ); |
| 134 | realColumName = splittedColumnName; |
| 135 | } |
| 136 | |
| 137 | return !currentModel || !currentModel.columnNames.includes(realColumName); |
| 138 | }); |
| 139 | |
| 140 | if (undefinedColumns.length > 0) { |
| 141 | throw new ApiError( |
| 142 | `Undefined column names: ${undefinedColumns.join(",")}`, |
| 143 | ); |
| 144 | } |
| 145 | |
| 146 | return conditions; |
| 147 | } |
| 148 | |
| 149 | private getUsedColumns(conditions: IQuery) { |
| 150 | return [ |
nothing calls this directly
no test coverage detected