Skip to content
Merged
Changes from 1 commit
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
20 changes: 13 additions & 7 deletions src/engine/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export type AbstractQueryValueElement =
| Date
| bigint

export type AbstractQuery = Record<
string,
AbstractQueryValueElement | AbstractQueryValueElement[]
>
export type AbstractQuery = Record<string, unknown>

/**
* Parses the query.
Expand Down Expand Up @@ -59,7 +56,7 @@ export type AbstractQueryOptions = {
/**
* How the abstract query is converted to an actual query.
*
* @default Each value that is not undefined is converted to a string by calling `.toString()`.
* @default Each value that is not undefined is converted to a string by calling `.toString()` or removed if not stringifyable.
*/
convertToQuery: (abstractQuery: Partial<AbstractQuery>) => Query
}
Expand All @@ -69,10 +66,19 @@ const DEFAULT_ABSTRACT_QUERY_OPTIONS: AbstractQueryOptions = {
const query: Query = {}
for (const [key, value] of Object.entries(abstractQuery)) {
if (Array.isArray(value)) {
query[key] = value.map((v) => v.toString())
query[key] = value.map((v: unknown) =>
typeof v?.toString === 'function'
? // eslint-disable-next-line @typescript-eslint/no-base-to-string
v.toString()
: '',
)
} else {
if (value !== undefined) {
query[key] = value.toString()
query[key] =
typeof value?.toString === 'function'
? // eslint-disable-next-line @typescript-eslint/no-base-to-string
value.toString()
: ''
}
}
}
Expand Down