Skip to content

Commit

Permalink
Fix backward compatibility for between condition
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubknejzlik committed Jan 30, 2024
1 parent 6dd7533 commit 413f32a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/Condition-serialization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ describe("Condition Serialization and Deserialization", () => {

// BETWEEN
it("should serialize and deserialize between condition", () => {
const condition = Conditions.between("foo", [1, 2]);
const condition = Conditions.between("foo", ["abcd", 2]);
const serialized = condition.toJSON();
const deserialized = Condition.fromJSON(serialized);
expect(deserialized.toSQL(flavor)).toEqual(condition.toSQL(flavor));

const json = {
type: "BetweenCondition",
key: "foo",
from: "abcd",
to: 2,
};
expect(Condition.fromJSON(json).toSQL(flavor)).toEqual(
condition.toSQL(flavor)
);
});

// IN
Expand Down
4 changes: 2 additions & 2 deletions src/Condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ class BetweenCondition implements Condition {
static fromJSON(json: any): BetweenCondition {
return new BetweenCondition(
Expression.deserialize(json.key),
Expression.deserialize(json.from),
Expression.deserialize(json.to)
Expression.deserializeValue(json.from),
Expression.deserializeValue(json.to)
);
}
}
Expand Down

0 comments on commit 413f32a

Please sign in to comment.