Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correctly validate relationship enum values in eq, neq and in methods #589

Open
wants to merge 1 commit into
base: validate-enum-values
Choose a base branch
from

Conversation

kamilogorek
Copy link
Member

Builds on top of #588

I couldn't find a nice way to remove duplication from ResolveFilterValue calls, and we need to branch out there, as ResolveFilterValue is sometimes wrapped in NonNullable, sometimes in ReadonlyArray and sometimes in nothing. Fallback values are also different.

In perfect world this would work, but I don't know hot to express a type for Wrapper as a generic accepting a single type 🤔

type ResolveFilterValue<
  Tables extends Record<string, GenericTable>,
  Row extends Record<string, unknown>,
  ColumnName extends string,
  Wrapper,
  Fallback
> = ColumnName extends `${infer RelationshipTable}.${infer RelationshipColumn}`
  ? ResolveFilterRelationshipValue<Tables, RelationshipTable, RelationshipColumn>
  : ColumnName extends keyof Row
  ? Wrapper extends Something
    ? Wrapper<Row[ColumnName]>
    : Row[ColumnName]
  : Fallback

Fixes #169
Fixes #351

I guess?™️

@kamilogorek kamilogorek force-pushed the validate-enum-values-for-relationships branch from 861ec34 to b058038 Compare December 31, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant