Skip to content

Commit

Permalink
Add bigint and boolean raw value support
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubknejzlik committed Aug 16, 2024
1 parent 04d9bc1 commit 59038e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
9 changes: 2 additions & 7 deletions src/Condition.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { Dayjs } from "dayjs";
import {
Expression,
ExpressionBase,
ExpressionValue,
ValueExpression,
} from "./Expression";
import { Expression, ExpressionBase, ExpressionValue } from "./Expression";
import { ISQLFlavor } from "./Flavor";
import { Q } from "./Query";
import { ISequelizable, ISerializable } from "./interfaces";
Expand Down Expand Up @@ -60,7 +55,7 @@ export class Condition implements ISequelizable, ISerializable {
}
}

export type ConditionValue = string | number | boolean | null | Dayjs;
export type ConditionValue = string | number | bigint | boolean | null | Dayjs;
type Operator = "=" | "!=" | ">" | "<" | ">=" | "<=";

class BinaryCondition extends Condition {
Expand Down
16 changes: 13 additions & 3 deletions src/Expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Condition, ConditionValue } from "./Condition";
import { ISQLFlavor } from "./Flavor";
import { ISequelizable, ISerializable } from "./interfaces";

export type ExpressionRawValue = string | number;
export type ExpressionRawValue = string | number | bigint | boolean;
export type ExpressionValue =
| ExpressionBase
| ExpressionRawValue
Expand Down Expand Up @@ -39,7 +39,12 @@ export class ExpressionBase implements ISerializable, ISequelizable {
return condition;
}
}
if (valueIsString || typeof value === "number") {
if (
valueIsString ||
typeof value === "number" ||
typeof value === "bigint" ||
typeof value === "boolean"
) {
const expr = new Expression(value);
return expr;
}
Expand Down Expand Up @@ -134,7 +139,12 @@ export class ValueExpression extends Expression {
return str.startsWith("!!!");
}
toSQL(flavor: ISQLFlavor): string {
if (typeof this.value === "number" || typeof this.value === "string") {
if (
typeof this.value === "number" ||
typeof this.value === "string" ||
typeof this.value === "bigint" ||
typeof this.value === "boolean"
) {
return flavor.escapeValue(this.value);
}
return this.value.toSQL(flavor);
Expand Down

0 comments on commit 59038e2

Please sign in to comment.