Skip to content

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

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

Merged
merged 4 commits into from
Jan 6, 2025

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
Base automatically changed from validate-enum-values to master January 6, 2025 09:28
@kamilogorek kamilogorek force-pushed the validate-enum-values-for-relationships branch from b058038 to 8ffe502 Compare January 6, 2025 09:33
@soedirgo soedirgo force-pushed the validate-enum-values-for-relationships branch from 8ffe502 to fdc0c6a Compare January 6, 2025 09:33
@kamilogorek kamilogorek enabled auto-merge January 6, 2025 09:38
@kamilogorek kamilogorek disabled auto-merge January 6, 2025 09:38
@kamilogorek kamilogorek enabled auto-merge (squash) January 6, 2025 09:38
Co-authored-by: Andrew Valleteau <[email protected]>
@soedirgo soedirgo force-pushed the validate-enum-values-for-relationships branch from ae993b1 to 697cc60 Compare January 6, 2025 10:28
@avallete avallete self-requested a review January 6, 2025 15:02
@kamilogorek kamilogorek merged commit 09083ea into master Jan 6, 2025
1 check passed
Copy link

github-actions bot commented Jan 6, 2025

🎉 This PR is included in version 1.17.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants