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

Function handleOneComparison

shared-dom/src/language/query2sql.ts:870–893  ·  view source on GitHub ↗
(
	val: number,
	context: Context,
	table: 'firstReview' | 'review' | 'note' | 'card' | undefined,
	column: 'created' | 'edited' | 'due',
	comparison: Comparison | undefined,
)

Source from the content-addressed store, hash-verified

868}
869
870function handleOneComparison(
871 val: number,
872 context: Context,
873 table: 'firstReview' | 'review' | 'note' | 'card' | undefined,
874 column: 'created' | 'edited' | 'due',
875 comparison: Comparison | undefined,
876) {
877 if (comparison == null) throwExp()
878 const comp = sql.raw(comparison)
879 if (table == null) {
880 const col = sql.raw(column)
881 context.parameterizeSql(
882 sql`(card.${col} ${comp} ${val} OR note.${col} ${comp} ${val})`,
883 )
884 } else {
885 if (column === 'due') {
886 context.parameterizeSql(sql`(card.due ${comp} ${val} AND card.due >= 0)`) // negative `due`s are not timestamps, but ordinals when the card is "new"
887 } else {
888 const tbl = sql.table(table)
889 const col = sql.raw(column)
890 context.parameterizeSql(sql`${tbl}.${col} ${comp} ${val}`)
891 }
892 }
893}
894
895function getJoinTableName(context: Context) {
896 context.joinTableName++

Callers 2

handleCreatedEditedDueFunction · 0.85
handleComparisonFunction · 0.85

Calls 2

throwExpFunction · 0.90
parameterizeSqlMethod · 0.80

Tested by

no test coverage detected