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

Function extractPrimitive

packages/effect/src/unstable/sql/Statement.ts:1476–1499  ·  view source on GitHub ↗
(
  value: unknown,
  onCustom: (
    type: Custom<string, unknown, unknown>,
    placeholder: (u: unknown) => string,
    withoutTransform: boolean
  ) => readonly [sql: string, binds: ReadonlyArray<unknown>],
  placeholder: (u: unknown) => string,
  withoutTransform: boolean
)

Source from the content-addressed store, hash-verified

1474}
1475
1476const extractPrimitive = (
1477 value: unknown,
1478 onCustom: (
1479 type: Custom<string, unknown, unknown>,
1480 placeholder: (u: unknown) => string,
1481 withoutTransform: boolean
1482 ) => readonly [sql: string, binds: ReadonlyArray<unknown>],
1483 placeholder: (u: unknown) => string,
1484 withoutTransform: boolean
1485): unknown => {
1486 if (value === undefined) {
1487 return null
1488 } else if (isFragment(value)) {
1489 const head = value.segments[0]
1490 if (head._tag === "Custom") {
1491 const compiled = onCustom(head, placeholder, withoutTransform)
1492 return compiled[1][0] ?? null
1493 } else if (head._tag === "Parameter") {
1494 return head.value
1495 }
1496 return null
1497 }
1498 return value
1499}
1500
1501const escapeSqlite = defaultEscape("\"")
1502

Callers 1

compileFunction · 0.85

Calls 2

isFragmentFunction · 0.85
onCustomFunction · 0.70

Tested by

no test coverage detected