Skip to content

Add support for single record queries by primary key #590

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

spitfire55
Copy link
Contributor

What kind of change does this PR introduce?

Users can now use [table_name]ByPk(key) queries to get a single record using the primary key

What is the current behavior?

No first-party support for single record queries by primary key.

See #554 .

What is the new behavior?

Adds a [table_name]ByPk(pk: pk_type) method to all tables that define a primary key

@imor
Copy link
Contributor

imor commented May 8, 2025

Hey @spitfire55 , thanks for this PR. We haven't forgotten this, just totally slammed right now. Will come back to it eventually.

@olirice before we review this, do you an opinion on the approach here. Do we want to add a method to access object by pk as implemented in this PR?

@olirice
Copy link
Contributor

olirice commented May 8, 2025

yes, i think there's been enough demand for it to justify the addition + it doesn't introduce any performance issues

Like Raminder mentioned, we're pretty slammed right now so it may take some time to work through this and review so sorry in advance for that!

From a very quick glance the things that jumped out are

  • lets filter the entities that automatically get these entrypoints to those that have primary keys of a type that's in a whitelist -> int, bigint, uuid, string are the ones that make sense to me
  • use exhaustive pattern matching where possible so its easier to find what needs updating when we extend enums in the future

appreciate your work on this, looking forward to getting it merged

spitfire55 and others added 3 commits May 13, 2025 16:26
- Fix TODO nodeId check, move out of transpile into builder
- Create SupportedPrimaryKeyType enum for PK type matching
@spitfire55 spitfire55 force-pushed the single_record_query_by_pk branch from 21cb2a1 to 59bc719 Compare May 13, 2025 20:26
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.

3 participants