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: Fix id alias columns typed as numbers. #1072

Merged
merged 2 commits into from
May 4, 2024
Merged

Conversation

stephenh
Copy link
Collaborator

@stephenh stephenh commented May 4, 2024

Previously the id column for like:

const a = alias(Author);
em.find(..., where: { a.id... });

The id column was typed as number, like the underlying database, instead of string to match our tagged ids.

This was because of a mistake in the entity codegen generation of the Fields interface, just using the wrong idType.

: FieldsOf<T>[P] extends { kind: "poly"; type: infer U extends Entity }
? PolyReferenceAlias<U>
: never;
[P in keyof FieldsOf<T>]: P extends "id"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a special case here for "id" to get it flipped from a PrimiviteAlias<string> to EntityAlias<T>, which seems more accurate.

@stephenh stephenh merged commit 8d71cce into main May 4, 2024
4 checks passed
@stephenh stephenh deleted the fix-alias-id-types branch May 4, 2024 12:45
stephenh pushed a commit that referenced this pull request May 4, 2024
## [1.163.7](v1.163.6...v1.163.7) (2024-05-04)

### Bug Fixes

* Fix id alias columns typed as numbers. ([#1072](#1072)) ([8d71cce](8d71cce))
@stephenh
Copy link
Collaborator Author

stephenh commented May 4, 2024

🎉 This PR is included in version 1.163.7 🎉

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
Development

Successfully merging this pull request may close these issues.

None yet

1 participant