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

Budi 9011 - DecodeId helper #15549

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

Budi 9011 - DecodeId helper #15549

wants to merge 6 commits into from

Conversation

mikesealey
Copy link
Collaborator

@mikesealey mikesealey commented Feb 13, 2025

Description

Carbon copy of packages/backend/backend-core/src/sql.utils.ts line 125 - this PR surfaces a Handlebars Helper to allow the user to un-encode a numeric ID from an SQL table. This is useful when fetching IDs from Form Blocks.

Addresses

#15428

Screenshots

When using the ID from the Form Block in the bindings, it is returned as an encoded array %5B /* ID HERE */%5D, but with this new helper decodeId we can extract the ID itself without any URI encoded square-brackets.

  • Black is the unprocessed ID from the form block {{ New Form Block.actor._id }}
  • Red is the new decodeId {{ decodeId New Repeater Block.actor._id }}
  • Blue is the existing decodeURI helper {{ decodeURI New Repeater Block.actor._id }}

image

Helper also returns a comma-separated string, when passed an array of numeric IDs.

  • Black is original, unprocessed array of numeric IDs %5B1%2C2%2C3%5D
  • Red is the new decodeId{{ decodeId "%5B1%2C2%2C3%5D" }}
  • Blue is the existing decodeURI {{ decodeURI "%5B1%2C2%2C3%5D" }}

image

Launchcontrol

Adds a decodeId helper for cleanly retrieving IDs from form-blocks

Copy link

linear bot commented Feb 13, 2025

Copy link

qa-wolf bot commented Feb 13, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@mikesealey mikesealey marked this pull request as ready for review February 13, 2025 16:11
@mikesealey mikesealey changed the title Budi 9011 Budi 9011 - DecodeId helper Feb 13, 2025
Copy link
Collaborator

@mike12345567 mike12345567 left a comment

Choose a reason for hiding this comment

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

Looks good! Only thing that would be helpful is to add a test case or two for this into the string-templates test cases!

I would test both invalid cases (passing strings that simply are not an encoded ID, as well as properly encoded IDs).

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.

2 participants