MCPcopy Create free account
hub / github.com/Effect-TS/effect / templateSegments

Function templateSegments

packages/effect/src/sql/Statement.ts:758–778  ·  view source on GitHub ↗
(strings: TemplateStringsArray, args: Array<any>)

Source from the content-addressed store, hash-verified

756 makeUnsafe(templateSegments(strings, args), acquirer, compiler, spanAttributes, transformRows, borrower, undefined)
757
758const templateSegments = (strings: TemplateStringsArray, args: Array<any>): Array<Segment> => {
759 const segments: Array<Segment> = strings[0].length > 0 ? [literal(strings[0])] : []
760
761 for (let i = 0; i < args.length; i++) {
762 const arg = args[i]
763
764 if (isFragment(arg)) {
765 segments.push(...arg.segments)
766 } else if (isSegment(arg)) {
767 segments.push(arg)
768 } else {
769 segments.push(parameter(arg))
770 }
771
772 if (strings[i + 1].length > 0) {
773 segments.push(literal(strings[i + 1]))
774 }
775 }
776
777 return segments
778}
779
780/**
781 * Creates a helper that joins SQL clauses with a literal separator, optionally

Callers 2

makeFunction · 0.85
statementFunction · 0.85

Calls 5

isFragmentFunction · 0.85
isSegmentFunction · 0.85
literalFunction · 0.70
parameterFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected