porsager / porsager/postgres

[question] How to get the query string before execution?

Open
#818 3 comments 2 reactions 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

let where = sql`col = 1`;
let query = sql`SELECT * FROM WHERE ${where}`;

let sql_as_string = query.(what?);

Hello. Is there any way to get the actual sql query string before/without the exucution?
I know we have sql.statement but it is not available before the query exucution and if the query has errors (while building it dynamically) I don't know how to debug it properly.

I found query.strings but it's...well not what i need.

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 reading the query.strings property and sql.statement behavior mentioned in the issue, then trace how dynamically built queries are represented before execution. Define what a pre-execution SQL representation should contain and how it should behave for queries that fail during construction; no implementation file or test is named.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, postgresql, typescript
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.