(literal: string, addParens = true, fallback = "")
| 437 | |
| 438 | /** @internal */ |
| 439 | export function join(literal: string, addParens = true, fallback = "") { |
| 440 | const literalStatement = new LiteralImpl(literal) |
| 441 | |
| 442 | return (clauses: ReadonlyArray<string | Statement.Fragment>): Statement.Fragment => { |
| 443 | if (clauses.length === 0) { |
| 444 | return unsafeFragment(fallback) |
| 445 | } else if (clauses.length === 1) { |
| 446 | return new FragmentImpl(convertLiteralOrFragment(clauses[0])) |
| 447 | } |
| 448 | |
| 449 | const segments: Array<Statement.Segment> = [] |
| 450 | |
| 451 | if (addParens) { |
| 452 | segments.push(new LiteralImpl("(")) |
| 453 | } |
| 454 | |
| 455 | segments.push.apply(segments, convertLiteralOrFragment(clauses[0])) |
| 456 | |
| 457 | for (let i = 1; i < clauses.length; i++) { |
| 458 | segments.push(literalStatement) |
| 459 | segments.push.apply(segments, convertLiteralOrFragment(clauses[i])) |
| 460 | } |
| 461 | |
| 462 | if (addParens) { |
| 463 | segments.push(new LiteralImpl(")")) |
| 464 | } |
| 465 | |
| 466 | return new FragmentImpl(segments) |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | /** @internal */ |
| 471 | export const and = join(" AND ", true, "1=1") |
no test coverage detected
searching dependent graphs…