MCPcopy Index your code
hub / github.com/simstudioai/sim / buildEmptyClause

Function buildEmptyClause

apps/sim/lib/table/sql.ts:559–565  ·  view source on GitHub ↗

* Builds an emptiness check against a JSONB cell. `isEmpty` matches null cells * (absent key or JSON null, both surfaced as SQL NULL by `->>`) and empty * strings; the negation requires the cell to be present and non-empty.

(tableName: string, field: string, isEmpty: boolean)

Source from the content-addressed store, hash-verified

557 * strings; the negation requires the cell to be present and non-empty.
558 */
559function buildEmptyClause(tableName: string, field: string, isEmpty: boolean): SQL {
560 const escapedField = field.replace(/'/g, "''")
561 const cell = sql.raw(`${tableName}.data->>'${escapedField}'`)
562 return isEmpty
563 ? sql`(${cell} IS NULL OR ${cell} = '')`
564 : sql`(${cell} IS NOT NULL AND ${cell} <> '')`
565}
566
567/**
568 * Builds a single ORDER BY clause for a field.

Callers 1

buildFieldConditionFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected