porsager / porsager/postgres

Dynamic values example does not work and appears syntactically incorrect.

Open
#716 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

Hello. Forgive my naivety please. I have been trying to figure out the API for the dynamic query for several hours.

In your docs you have the following example:

const [{ a, b, c }] => await sql`
  select
    *
  from (values ${ sql(['a', 'b', 'c']) }) as x(a, b, c)
`

This example appears incorrect to my code editor because the input arguments are not defined. I assume that the array ['a', 'b', 'c'] is supposed to instead be [a, b, c] as the input, however this does not work either. I keep getting the error PostgresError: there is no parameter $1.

I have tried looking at other issues and seeing how other people are doing it, however I can't get a basic example of this working, so I am at a loss of what to do.

Any help would be appreciated, thank you!

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

Start with the dynamic values example quoted in the issue and review the surrounding documentation for the intended API and query syntax. Verify a corrected basic example against PostgreSQL; done means the example no longer references undefined values and runs without the “there is no parameter $1” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgresql
Domain
databases, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.