xialvjun / xialvjun/ts-sql-plugin

sql.mock is not working while using separately

Open
#38 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
195
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Code:

const startDateSql = sql.mock<'2022-01-01T00:00:00.0Z'>(startDate.toISOString())
const endDateSql = sql.mock<'2023-01-01T00:00:00.0Z'>(endDate.toISOString())

const query = sql`
   SELECT
       ${startDateSql}::timestamp with time zone AS "start",
       ${endDateSql}::timestamp with time zone AS "end"
   ...
`

ts-sql-plugin:

ERROR:  cannot cast type integer to timestamp with time zone
LINE 3:                     0::timestamp with time zone AS "start",

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 at the sql.mock helper and the sql tagged-template entry point; use the supplied TypeScript reproduction to trace how separately mocked values are rendered. Done means the reproduced query no longer emits 0 for either mock and the timestamp casts succeed.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql, typescript
Domain
databases, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.