Greedy "select" builder?
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
Given
const data = { name: "foo" }
The following
with cf as (insert into app.custom_field as cf ${sql(data)} returning cf) ...
is translated to
with cf as (insert into app.custom_field as cf $1 as \"name\" returning cf) ...
while I expect vanilla insert-like expansion like
with cf as (insert into app.custom_field as cf (name)values($1) returning cf) ...
Traces led to as cf token forces the statement to be treated as "select" builder, not "insert" one.
Please consider fixing or pointing out how to gracefully work this around.
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
Reproduce the issue with the shown data object and SQL template, then inspect the builder path that classifies the as cf token. Done when this form expands to (name)values($1) like the expected SQL without breaking the surrounding CTE and returning clause.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100