porsager / porsager/postgres

Issue on GRANT query

Open
#1,101 0 comments 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

I'm having trouble running grant queries.

The variables are:
tableArray = ['schema.table1','schema.table2']
roleName = 'example'

This query works fine:
GRANT INSERT ON ${this.sql(tableArray)} TO ${this.sql(roleName)}

the generated query is correct:
GRANT SELECT ON "schema"."table1","schema"."table2" TO "example"

This one doesn't work:
GRANT UPDATE ON ${this.sql(tableArray)} TO ${this.sql(roleName)}

the generated query is invalid:
GRANT UPDATE ON "0"=$1,"1"=$2 TO "example"

Is this a bug in the system that understands what to replace in the query?

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 by tracing the sql interpolation behavior for tableArray in the postgres.js query builder, comparing the generated GRANT INSERT and GRANT UPDATE statements shown in the report. Reproduce the example with the two table names and role, then confirm that the UPDATE form generates valid PostgreSQL GRANT SQL rather than the "0"=$1,"1"=$2 output.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.