postgres: Feature request: Support creating SQL fragments using tagged literal
Open
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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