(path: string, relation?: string)
| 186 | } |
| 187 | |
| 188 | const fieldExpr = (path: string, relation?: string): string => { |
| 189 | if (path === idKey || path === "id") return "id" |
| 190 | if (relation && path.includes(".-1.")) { |
| 191 | const subPath = path.split(".-1.")[1]! |
| 192 | if (subPath.endsWith(".length")) { |
| 193 | // TODO: array length inside relation element |
| 194 | return dialect.jsonExtractElement(`_${relation}`, subPath.slice(0, -".length".length)) |
| 195 | } |
| 196 | return dialect.jsonExtractElement(`_${relation}`, subPath) |
| 197 | } |
| 198 | if (path.endsWith(".length")) { |
| 199 | const arrPath = dottedToJsonPath(path.slice(0, -".length".length)) |
| 200 | return dialect.arrayLength(arrPath) |
| 201 | } |
| 202 | const jsonPath = dottedToJsonPath(path) |
| 203 | const expr = dialect.jsonExtract(jsonPath) |
| 204 | const topKey = path.split(".")[0] |
| 205 | if (topKey in defaultValues) { |
| 206 | return `COALESCE(${expr}, ${addParam(defaultValues[topKey])})` |
| 207 | } |
| 208 | return expr |
| 209 | } |
| 210 | |
| 211 | const statement = (x: FilterR, relation?: string): string => { |
| 212 | const resolvedPath = x.path === idKey ? "id" : x.path |
no test coverage detected
searching dependent graphs…