( indexToPlaceholder: (i: number) => string, formatIdentifier: (s: string)=> string, )
| 55 | }; |
| 56 | |
| 57 | compile( |
| 58 | indexToPlaceholder: (i: number) => string, |
| 59 | formatIdentifier: (s: string)=> string, |
| 60 | ): CompiledQuery { |
| 61 | let sql = ''; |
| 62 | const params: any[] = []; |
| 63 | |
| 64 | const recursivelyAddParts = (parts: ReadonlyArray<QueryPart>) => { |
| 65 | for (let i = 0; i < parts.length; i++) { |
| 66 | if (parts[i] instanceof SqlQuery) { |
| 67 | recursivelyAddParts((<SqlQuery>parts[i]).parts); |
| 68 | } else if (parts[i] instanceof QueryParam) { |
| 69 | sql += indexToPlaceholder(params.length); |
| 70 | params.push((<QueryParam>parts[i]).param); |
| 71 | } else if (parts[i] instanceof QueryIdentifier) { |
| 72 | sql += formatIdentifier((<QueryIdentifier>parts[i]).identifier); |
| 73 | } else { |
| 74 | sql += parts[i]; |
| 75 | } |
| 76 | } |
| 77 | }; |
| 78 | recursivelyAddParts(this.parts); |
| 79 | |
| 80 | return new CompiledQuery(sql, params); |
| 81 | } |
| 82 | } |
no outgoing calls
no test coverage detected