| 1486 | } |
| 1487 | |
| 1488 | get(sql: string, parameterTypes: ReadonlyArray<number>, textResults: boolean): Prepared { |
| 1489 | const key = `${textResults ? "T" : "B"}\u0000${parameterTypes.join(",")}\u0000${sql}` |
| 1490 | const found = this.statements.get(key) |
| 1491 | if (found !== undefined) { |
| 1492 | // Re-insert to move it to the end: `Map` iterates in insertion order, so |
| 1493 | // the first key is the least recently used one. |
| 1494 | this.statements.delete(key) |
| 1495 | this.statements.set(key, found) |
| 1496 | this.trim(found) |
| 1497 | return found |
| 1498 | } |
| 1499 | const prepared: Prepared = { |
| 1500 | name: `effect_${this.namespace}_${++this.counter}`, |
| 1501 | key, |
| 1502 | ready: false, |
| 1503 | parsing: false, |
| 1504 | description: undefined |
| 1505 | } |
| 1506 | this.statements.set(key, prepared) |
| 1507 | this.trim(prepared) |
| 1508 | return prepared |
| 1509 | } |
| 1510 | |
| 1511 | /** |
| 1512 | * A statement still being parsed cannot be closed yet: its `Parse` may not |