Skip to content

Commit

Permalink
Update $in to accept readonly (#965) (#968)
Browse files Browse the repository at this point in the history
* Update Where In to be Readonly

* changeset

* Add small test

* changeset
  • Loading branch information
nihalbhatnagar authored Nov 13, 2024
1 parent fa5119a commit eae3b9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/rich-cats-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@osdk/client": patch
"@osdk/api": patch
---

Allows $in to take a readonly array
2 changes: 1 addition & 1 deletion packages/api/src/aggregate/WhereClause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type MakeFilter<K extends PossibleWhereClauseFilters, V> = K extends string ? {
type BaseFilter<T> =
| T
| MakeFilter<"$eq" | "$ne", T>
| MakeFilter<"$in", Array<T>>
| MakeFilter<"$in", ReadonlyArray<T>>
| MakeFilter<"$isNull", boolean>;

type StringFilter =
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/objectSet/ObjectSet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ describe("ObjectSet", () => {
}
});

it("allows $in filter with ReadonlyArrays", () => {
const ids: ReadonlyArray<number> = [50030, 50031];
const objectSet = client(Employee).where({
employeeId: { $in: ids },
});
expect(objectSet).toBeDefined();
});

describe.each(["fetchPage", "fetchPageWithErrors"] as const)("%s", (k) => {
// describe("strictNonNull: \"drop\"", () => {
// describe("includeRid: true", () => {
Expand Down

0 comments on commit eae3b9e

Please sign in to comment.