/opt/canhelp/node_modules/kysely/dist/cjs/query-builder
Edit: /opt/canhelp/node_modules/kysely/dist/cjs/query-builder/case-builder.d.ts (6689B)
import type { Expression } from '../expression/expression.js';
import { ExpressionWrapper } from '../expression/expression-wrapper.js';
import type { ReferenceExpression } from '../parser/reference-parser.js';
import { CaseNode } from '../operation-node/case-node.js';
import { type ComparisonOperatorExpression, type OperandValueExpressionOrList } from '../parser/binary-operation-parser.js';
import { type ExtractTypeFromValueExpression } from '../parser/value-parser.js';
import type { KyselyTypeError } from '../util/type-error.js';
export declare class CaseBuilder
implements Whenable {
#private;
constructor(props: CaseBuilderProps);
/**
* Adds a `when` clause to the case statement.
*
* A `when` call must be followed by a {@link CaseThenBuilder.then} call.
*/
when, VE extends OperandValueExpressionOrList>(lhs: unknown extends W ? RE : KyselyTypeError<'when(lhs, op, rhs) is not supported when using case(value)'>, op: ComparisonOperatorExpression, rhs: VE): CaseThenBuilder;
when(expression: Expression): CaseThenBuilder;
when(value: unknown extends W ? KyselyTypeError<'when(value) is only supported when using case(value)'> : W): CaseThenBuilder;
}
interface CaseBuilderProps {
readonly node: CaseNode;
}
export declare class CaseThenBuilder {
#private;
constructor(props: CaseBuilderProps);
/**
* Adds a `then` clause to the `case` statement.
*
* A `then` call can be followed by {@link Whenable.when}, {@link CaseWhenBuilder.else},
* {@link CaseWhenBuilder.end} or {@link CaseWhenBuilder.endCase} call.
*
* **Note:** Numbers, booleans, and `null` values are inlined directly into the
* SQL query string (e.g. `then 1`, `then true`, `then null`) instead of being
* added as parameterized values (e.g. `then $1`). This allows the database
* engine to correctly infer the data type of the `case` expression result.
* Without this behavior, all results would be returned as strings.
*
* String values are always parameterized as usual.
*/
then>(expression: E): CaseWhenBuilder>;
then(value: V): CaseWhenBuilder;
}
export declare class CaseWhenBuilder implements Whenable, Endable {
#private;
constructor(props: CaseBuilderProps);
/**
* Adds a `when` clause to the case statement.
*
* A `when` call must be followed by a {@link CaseThenBuilder.then} call.
*/
when, VE extends OperandValueExpressionOrList>(lhs: unknown extends W ? RE : KyselyTypeError<'when(lhs, op, rhs) is not supported when using case(value)'>, op: ComparisonOperatorExpression, rhs: VE): CaseThenBuilder;
when(expression: Expression): CaseThenBuilder;
when(value: unknown extends W ? KyselyTypeError<'when(value) is only supported when using case(value)'> : W): CaseThenBuilder;
/**
* Adds an `else` clause to the `case` statement.
*
* An `else` call must be followed by an {@link Endable.end} or {@link Endable.endCase} call.
*
* **Note:** Numbers, booleans, and `null` values are inlined directly into the
* SQL query string (e.g. `else 0`, `else false`, `else null`) instead of being
* added as parameterized values (e.g. `else $1`). This allows the database
* engine to correctly infer the data type of the `case` expression result.
* Without this behavior, all results would be returned as strings.
*
* String values are always parameterized as usual.
*/
else>(expression: E): CaseEndBuilder>;
else(value: V): CaseEndBuilder;
/**
* Adds an `end` keyword to the case operator.
*
* `case` operators can only be used as part of a query.
* For a `case` statement used as part of a stored program, use {@link endCase} instead.
*/
end(): ExpressionWrapper;
/**
* Adds `end case` keywords to the case statement.
*
* `case` statements can only be used for flow control in stored programs.
* For a `case` operator used as part of a query, use {@link end} instead.
*/
endCase(): ExpressionWrapper;
}
export declare class CaseEndBuilder implements Endable {
#private;
constructor(props: CaseBuilderProps);
/**
* Adds an `end` keyword to the case operator.
*
* `case` operators can only be used as part of a query.
* For a `case` statement used as part of a stored program, use {@link endCase} instead.
*/
end(): ExpressionWrapper;
/**
* Adds `end case` keywords to the case statement.
*
* `case` statements can only be used for flow control in stored programs.
* For a `case` operator used as part of a query, use {@link end} instead.
*/
endCase(): ExpressionWrapper;
}
interface Whenable {
/**
* Adds a `when` clause to the case statement.
*
* A `when` call must be followed by a {@link CaseThenBuilder.then} call.
*/
when, VE extends OperandValueExpressionOrList>(lhs: unknown extends W ? RE : KyselyTypeError<'when(lhs, op, rhs) is not supported when using case(value)'>, op: ComparisonOperatorExpression, rhs: VE): CaseThenBuilder;
when(expression: Expression): CaseThenBuilder;
when(value: unknown extends W ? KyselyTypeError<'when(value) is only supported when using case(value)'> : W): CaseThenBuilder;
}
interface Endable {
/**
* Adds an `end` keyword to the case operator.
*
* `case` operators can only be used as part of a query.
* For a `case` statement used as part of a stored program, use {@link endCase} instead.
*/
end(): ExpressionWrapper;
/**
* Adds `end case` keywords to the case statement.
*
* `case` statements can only be used for flow control in stored programs.
* For a `case` operator used as part of a query, use {@link end} instead.
*/
endCase(): ExpressionWrapper;
}
export {};