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

Function statement

packages/effect/src/unstable/sql/Statement.ts:618–645  ·  view source on GitHub ↗
(
  acquirer: Acquirer,
  compiler: Compiler,
  strings: TemplateStringsArray,
  args: Array<any>,
  spanAttributes: ReadonlyArray<readonly [string, unknown]>,
  transformRows: (<A extends object>(row: ReadonlyArray<A>) => ReadonlyArray<A>) | undefined
)

Source from the content-addressed store, hash-verified

616 * @since 4.0.0
617 */
618export const statement = <A = Row>(
619 acquirer: Acquirer,
620 compiler: Compiler,
621 strings: TemplateStringsArray,
622 args: Array<any>,
623 spanAttributes: ReadonlyArray<readonly [string, unknown]>,
624 transformRows: (<A extends object>(row: ReadonlyArray<A>) => ReadonlyArray<A>) | undefined
625): Statement<A> => {
626 const segments: Array<Segment> = strings[0].length > 0 ? [literal(strings[0])] : []
627
628 for (let i = 0; i < args.length; i++) {
629 const arg = args[i]
630
631 if (isFragment(arg)) {
632 segments.push(...arg.segments)
633 } else if (isSegment(arg)) {
634 segments.push(arg)
635 } else {
636 segments.push(parameter(arg))
637 }
638
639 if (strings[i + 1].length > 0) {
640 segments.push(literal(strings[i + 1]))
641 }
642 }
643
644 return makeUnsafe(segments, acquirer, compiler, spanAttributes, transformRows)
645}
646
647/**
648 * Creates a helper that joins SQL clauses with a literal separator, optionally

Callers 1

makeFunction · 0.85

Calls 6

isFragmentFunction · 0.85
isSegmentFunction · 0.85
parameterFunction · 0.85
pushMethod · 0.80
literalFunction · 0.70
makeUnsafeFunction · 0.70

Tested by

no test coverage detected