MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / buildCondition

Method buildCondition

packages/db/src/clickhouse/query-builder.ts:158–182  ·  view source on GitHub ↗
(
    column: string,
    operator: Operator,
    value?: SqlParam
  )

Source from the content-addressed store, hash-verified

156 }
157
158 public buildCondition(
159 column: string,
160 operator: Operator,
161 value?: SqlParam
162 ): string {
163 switch (operator) {
164 case 'IS NULL':
165 return `${column} IS NULL`;
166 case 'IS NOT NULL':
167 return `${column} IS NOT NULL`;
168 case 'BETWEEN':
169 if (Array.isArray(value) && value.length === 2) {
170 return `${column} BETWEEN ${this.escapeValue(value[0]!)} AND ${this.escapeValue(value[1]!)}`;
171 }
172 throw new Error('BETWEEN operator requires an array of two values');
173 case 'IN':
174 case 'NOT IN':
175 if (!(Array.isArray(value) || value instanceof Expression)) {
176 throw new Error(`${operator} operator requires an array value`);
177 }
178 return `${column} ${operator} ${this.escapeValue(value)}`;
179 default:
180 return `${column} ${operator} ${this.escapeValue(value!)}`;
181 }
182 }
183
184 andWhere(column: string, operator: Operator, value?: SqlParam): this {
185 const condition = this.buildCondition(column, operator, value);

Callers 9

whereMethod · 0.95
andWhereMethod · 0.95
orWhereMethod · 0.95
havingMethod · 0.95
andHavingMethod · 0.95
orHavingMethod · 0.95
whereMethod · 0.80
andWhereMethod · 0.80
orWhereMethod · 0.80

Calls 1

escapeValueMethod · 0.95

Tested by

no test coverage detected