Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 148x 120x 120x 119x 119x 118x 120x 120x 1016x 875x 875x 875x 875x 875x 875x 387x 339x 339x 339x 339x | import { SqlExpression, type SqlExpressionVisitor } from './expression.ts';
/** JSON path access or JSON conditions. Created by {@link json}. */
export class Json extends SqlExpression {
/** @internal */
static override readonly kind = 'Json';
/** Dot-separated path starting with the attribute name. */
readonly path?: string;
/** Conditions object. */
readonly conditions?: object;
/** Value compared with the path (`undefined`: no comparison). */
readonly value?: string | number | boolean | null;
/**
* @param conditionsOrPath - Dot-separated path or conditions object.
* @param value - Value compared with the path.
*/
constructor(conditionsOrPath: string | object, value?: string | number | boolean | null) {
super();
if (typeof conditionsOrPath === 'string') {
this.path = conditionsOrPath;
this.value = value;
} else {
this.conditions = conditionsOrPath;
}
Object.freeze(this);
}
/** @internal */
accept<R>(visitor: SqlExpressionVisitor<R>): R {
return visitor.visitJson(this);
}
}
/** Comparison of an arbitrary expression with a value. Created by {@link where}. */
export class Where extends SqlExpression {
/** @internal */
static override readonly kind = 'Where';
/** Left-hand expression. */
readonly attribute: unknown;
/** Comparison operator. */
readonly comparator: string | symbol;
/** Right-hand value. */
readonly logic: unknown;
/**
* @param attribute - Left-hand expression.
* @param comparator - Comparison operator.
* @param logic - Right-hand value.
*/
constructor(attribute: unknown, comparator: string | symbol, logic: unknown) {
super();
this.attribute = attribute;
this.comparator = comparator;
this.logic = logic;
Object.freeze(this);
}
/** @internal */
accept<R>(visitor: SqlExpressionVisitor<R>): R {
return visitor.visitWhere(this);
}
}
/** Reference to a column of the row proposed for insertion in `ON CONFLICT DO UPDATE`. Created by {@link excluded}. */
export class Excluded extends SqlExpression {
/** @internal */
static override readonly kind = 'Excluded';
/** Attribute name. */
readonly column: string;
/**
* @param column - Attribute name.
*/
constructor(column: string) {
super();
this.column = column;
Object.freeze(this);
}
/** @internal */
accept<R>(visitor: SqlExpressionVisitor<R>): R {
return visitor.visitExcluded(this);
}
}
|