MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / serialize

Function serialize

shared-dom/src/language/query2sql.ts:570–647  ·  view source on GitHub ↗
(node: Node, context: Context)

Source from the content-addressed store, hash-verified

568}
569
570function serialize(node: Node, context: Context) {
571 switch (node.type) {
572 case simpleString:
573 case quoted:
574 case html:
575 case number:
576 case date:
577 case regex: {
578 const name = getJoinTableName(context)
579 if (node.type === 'Regex') {
580 context.joinNoteFieldValue.push({
581 name,
582 sql: handleField(
583 node,
584 regexpWithFlags(node, `noteFieldValue.value`, true),
585 ),
586 })
587 } else if (node.type === 'Html') {
588 context.joinNoteValueFts.push({
589 name,
590 sql: handleField(
591 node,
592 glob(node, `noteValueFts`, `value`, true, '0'),
593 ),
594 })
595 } else {
596 context.joinNoteValueFts.push({
597 name,
598 sql: handleField(node, glob(node, `noteValueFts`, `value`, true)),
599 })
600 }
601 context.trustedSql(`${name}.z IS ${node.negate ? '' : 'NOT'} NULL`) // `z` from 2DB5DD73-603E-4DF7-A366-A53375AF0093
602 if (!node.negate && node.fieldValueHighlight != null) {
603 context.fieldValueHighlight.push(node.fieldValueHighlight)
604 }
605 break
606 }
607 case group: {
608 const paren = !node.isRoot
609 if (paren) {
610 if (node.negate) context.trustedSql('NOT')
611 context.trustedSql('(')
612 }
613 if (node.label == null) {
614 for (const child of node.children) {
615 serialize(child, context)
616 }
617 } else {
618 for (const child of node.children) {
619 switch (child.type) {
620 case simpleString:
621 case quoted:
622 case number:
623 case date:
624 case html:
625 case regex:
626 handleLabel(child, context)
627 break

Callers 2

convertFunction · 0.70
handleLabelFunction · 0.70

Calls 7

assertNeverFunction · 0.90
getJoinTableNameFunction · 0.85
handleFieldFunction · 0.85
regexpWithFlagsFunction · 0.85
globFunction · 0.85
handleLabelFunction · 0.85
trustedSqlMethod · 0.80

Tested by

no test coverage detected