fix(striker-ui-api): remove empty functions in buildCondition functions

main
Tsu-ba-me 2 years ago
parent 28e12251d6
commit 72e070bc38
  1. 9
      striker-ui-api/src/lib/buildCondition.ts

@ -1,3 +1,4 @@
import call from './call';
import join from './join'; import join from './join';
import { sanitizeQS } from './sanitizeQS'; import { sanitizeQS } from './sanitizeQS';
@ -5,9 +6,11 @@ const buildIDCondition = (
keys: Parameters<JoinFunction>[0], keys: Parameters<JoinFunction>[0],
conditionPrefix: string, conditionPrefix: string,
{ {
onFallback = () => '', onFallback,
beforeReturn = (result) => beforeReturn = (result) =>
result ? `${conditionPrefix} IN (${result})` : onFallback(), result
? `${conditionPrefix} IN (${result})`
: call(onFallback, { notCallableReturn: '' }),
}: Pick<JoinOptions, 'beforeReturn'> & { onFallback?: () => string } = {}, }: Pick<JoinOptions, 'beforeReturn'> & { onFallback?: () => string } = {},
) => ) =>
join(keys, { join(keys, {
@ -19,7 +22,7 @@ const buildIDCondition = (
export const buildUnknownIDCondition = ( export const buildUnknownIDCondition = (
keys: unknown, keys: unknown,
conditionPrefix: string, conditionPrefix: string,
{ onFallback = () => '' }: { onFallback?: () => string }, { onFallback }: { onFallback?: () => string },
): { after: string; before: string[] } => { ): { after: string; before: string[] } => {
const before = sanitizeQS(keys, { const before = sanitizeQS(keys, {
modifierType: 'sql', modifierType: 'sql',

Loading…
Cancel
Save