vercel / vercel/storage

postgres: Feature request: Support creating SQL fragments using tagged literal

Open
#415 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

storage: postgres
Dominant language
TypeScript
Stars
595
Forks
101
Avg merge
2h 24m
Merged PRs (30d)
1

Description

I've opened a PR (https://github.com/vercel/storage/pull/395) to add another tagged literal, called fragment. When you create a fragment it can be used in a sql tagged literal.

Example usage:

const sharedValues = fragment`${123}, ${'admin'}`;
await sql`INSERT INTO users (id, credits, role) VALUES (1, ${sharedValues}), (2, ${sharedValues})`;
const column = isFoo ? fragment`foo` : fragment`bar`;
const filter = fragment`${column} = ${123}`;
return sql`SELECT ${column} FROM table WHERE ${filter}`;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the linked PR #395 first, since it contains the proposed implementation of the fragment tagged literal. Compare its behavior with the SQL examples in this issue, including reused value fragments and nested column/filter fragments. Done means the documented fragment usages work correctly within sql tagged literals.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgres, typescript
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.