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

Introduce concept of SQL-able to pg-sql2 #1994

Merged
merged 5 commits into from
Mar 14, 2024
Merged

Introduce concept of SQL-able to pg-sql2 #1994

merged 5 commits into from
Mar 14, 2024

Conversation

benjie
Copy link
Member

@benjie benjie commented Mar 14, 2024

Description

Writing sql`${$user.getClassStep().alias}.is_admin is true` is a chore; this change makes it so that sql can recognize embedded values that can be turned natively into SQL, for example pgSelect and pgSelectSingle can now be used like: sql`${$user}.is_admin is true` which is much simpler and easier to read.

Note: this is only useful for aliases, you cannot use this for placeholders.

Performance impact

Negligible, planning only.

Security impact

I guess you could argue that it's slightly more magic, and thus slightly riskier that the coder might do the wrong thing? I can't see how this would turn into a vulnerability that would get past testing though.

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.

Copy link

changeset-bot bot commented Mar 14, 2024

🦋 Changeset detected

Latest commit: 7819fde

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
graphile-build-pg Patch
postgraphile Patch
@dataplan/pg Patch
pg-sql2 Patch
graphile-utils Patch
pgl Patch
graphile Patch
@localrepo/grafast-bench Patch
@dataplan/json Patch
@grafserv/persisted Patch
grafserv Patch
ruru-components Patch
@localrepo/grafast-website Patch
graphile-build Patch
graphile-export Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@benjie benjie merged commit 7ff2b2b into main Mar 14, 2024
24 checks passed
@benjie benjie deleted the to-sql branch March 14, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant