Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

fix(excludeNone): fix when array is empty #61

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/database/AcebaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class AceBaseClient implements Database {
if (orderFilter.nonce != undefined) {
query.filter('order/nonce', '==', orderFilter.nonce);
}
if (orderFilter.excludeNonces != undefined) {
if (orderFilter.excludeNonces?.length && orderFilter.excludeNonces?.length > 0) {
query.filter('order/nonce', '!in', orderFilter.excludeNonces);
}
if (orderFilter.senderWallet != undefined) {
Expand Down Expand Up @@ -225,7 +225,7 @@ export class AceBaseClient implements Database {
if (orderFilter.nonce != undefined) {
query.filter('order/nonce', '==', orderFilter.nonce);
}
if (orderFilter.excludeNonces != undefined) {
if (orderFilter.excludeNonces?.length && orderFilter.excludeNonces?.length > 0) {
query.filter('order/nonce', '!in', orderFilter.excludeNonces);
}
if (orderFilter.signerTokens != undefined) {
Expand Down
5 changes: 5 additions & 0 deletions src/database/__tests__/Database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ describe("Database implementations", () => {

const byExcludedNonce = await db.getOrdersERC20By({ offset: 0, limit: 10, excludeNonces: ["123"] });
expect(Object.keys(byExcludedNonce.orders)).toEqual(["id3", "id2"]);
const byExcludedNonceEmpty = await db.getOrdersERC20By({ offset: 0, limit: 10, excludeNonces: [], sortField: SortField.NONCE, sortOrder: SortOrder.ASC });
expect(Object.keys(byExcludedNonceEmpty.orders)).toEqual(["id3", "id1", "id2"]);

const byChainId = await db.getOrdersERC20By({ offset: 0, limit: 10, chainId: 15 });
expect(Object.keys(byChainId.orders)).toEqual(["id1"]);
Expand Down Expand Up @@ -540,6 +542,9 @@ describe("Database implementations", () => {

const byExcludedNonce = await db.getOrdersBy({ offset: 0, limit: 10, excludeNonces: ["123"] });
expect(Object.keys(byExcludedNonce.orders)).toEqual(["id3", "id2"]);

const byExcludedNonceEmpty = await db.getOrdersBy({ offset: 0, limit: 10, excludeNonces: [], sortOrder: SortOrder.ASC, sortField: SortField.NONCE });
expect(Object.keys(byExcludedNonceEmpty.orders)).toEqual(["id3", "id1", "id2"]);

const byChainId = await db.getOrdersBy({ offset: 0, limit: 10, chainId: 15 });
expect(Object.keys(byChainId.orders)).toEqual(["id1"]);
Expand Down