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

Add .unaryValue to ExecutionValue #2324

Merged
merged 3 commits into from
Jan 17, 2025
Merged

Add .unaryValue to ExecutionValue #2324

merged 3 commits into from
Jan 17, 2025

Conversation

benjie
Copy link
Member

@benjie benjie commented Jan 17, 2025

Description

ExecutionValue comes in two flavours: batch and unary. Unary has a .value and batch has a .entries. Previously we included : never versions of each of these to make access easier, but this could lead to mistakes. This interface has been removed (:rotating_light: breaking! but only the types) so you'll need to narrow via .isBatch before you can use the relevant property.

When you knew an execution value was unary, you could use .at(0) to access its value; however this was risky because there was no assertion that the value is unary. To help mitigate this, I've added the new .unaryValue() method which asserts that the value is unary and then accesses the singular value from it; this should make code safer when you know a $step should be unary due to calling this.addUnaryDependency($step).

Performance impact

Negligible.

Security impact

Improvement: increased safety. Risk: assertions.

Checklist

  • My code matches the project's code style and yarn lint:fix passes.
  • I've added tests for the new feature, and yarn test passes.
  • I have detailed the new feature in the relevant documentation.
  • I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists).
  • If this is a breaking change I've explained why.

…es (you need to narrow to access these). Added new `.unaryValue()` that can be used to assert the value is unary and retrieve its value - this should be used instead of `.at(0)` in general.
Base automatically changed from scoped-sql to main January 17, 2025 19:19
@benjie benjie merged commit 56f899a into main Jan 17, 2025
42 checks passed
@benjie benjie deleted the unary-tweaks branch January 17, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

1 participant