(lit: string, addParens = true, fallback = "")
| 652 | } |
| 653 | |
| 654 | if (strings[i + 1].length > 0) { |
| 655 | segments.push(literal(strings[i + 1])) |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | return makeUnsafe(segments, acquirer, compiler, spanAttributes, transformRows, borrower) |
| 660 | } |
| 661 | |
| 662 | /** |
| 663 | * Creates a helper that joins SQL clauses with a literal separator, optionally |
| 664 | * wrapping multiple clauses in parentheses and using a fallback for an empty |
| 665 | * list. |
| 666 | * |
| 667 | * @category constructors |
| 668 | * @since 4.0.0 |
| 669 | */ |
| 670 | export function join(lit: string, addParens = true, fallback = "") { |
| 671 | const literalStatement = literal(lit) |
| 672 | const fallbackFragment = fragment([literal(fallback)]) |
| 673 | |
| 674 | return (clauses: ReadonlyArray<string | Fragment>): Fragment => { |
| 675 | if (clauses.length === 0) { |
| 676 | return fallbackFragment |
| 677 | } else if (clauses.length === 1) { |
| 678 | return fragment(convertLiteralOrFragment(clauses[0])) |
| 679 | } |
| 680 | |
| 681 | const segments: Array<Segment> = [] |
| 682 | |
| 683 | if (addParens) { |
| 684 | segments.push(literal("(")) |
| 685 | } |
| 686 | |
| 687 | segments.push.apply(segments, convertLiteralOrFragment(clauses[0])) |
no test coverage detected
searching dependent graphs…