porsager / porsager/postgres

The type ‘TransactionSql<{}>’ has no call signature.

Open
#1,150 5 comments 13 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

Hi,

With new version 3.4.8, I have types validation errors when I use transaction. If I rollback to 3.4.7, I have no problem :

await sql.begin(async (sql) => {
        for (const data of message.data) {
            // Impossible to call sql`` or sql() inside sql.begin
            // because the type ‘TransactionSql<{}>’ has no call signature.
            await sql`
                insert into ${sql(`${message.company}_measures`)} (
                    time, place, point, type, label, value,
                    receptionTime, sequence,
                    durationControl, statusControl,
                    isControlled, isQualified,
                    controlMessages
                ) values (
                    ${message.time}, ${message.place}, ${message.point}, ${data.type}, ${data.label}, ${data.value},
                    ${message.receptionTime || null}, ${message.sequence || null},
                    ${data.durationControl ?? null}, ${data.statusControl || '02_success_noControls'},
                    ${data.isControlled ?? true}, ${data.isQualified ?? true},
                    ${data.controlMessages ? JSON.stringify(data.controlMessages) : null}
                )
            `;
        }
    });

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

Reproduce the type-checking error with the sql.begin snippet and compare the transaction typings between versions 3.4.8 and 3.4.7. Trace how TransactionSql is defined and verify that the resulting types allow sql`` or sql() inside the transaction callback without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, postgresql, typescript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.