MCPcopy Create free account
hub / github.com/effect-app/libs / join

Function join

repos/effect/packages/effect/src/unstable/sql/Statement.ts:654–684  ·  view source on GitHub ↗
(lit: string, addParens = true, fallback = "")

Source from the content-addressed store, hash-verified

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 */
670export 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]))

Callers 1

Statement.tsFile · 0.70

Calls 4

fragmentFunction · 0.85
convertLiteralOrFragmentFunction · 0.85
pushMethod · 0.80
literalFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…