Skip to content

It should be great to be able to start a transaction inside a transaction #985

Closed

Description

@ecochard

nothing to do with real postgres transactions
but logically it should be great to be able to imbricate transactions inside the code.

just add something like

transactionSql.begin = ( callback ) => {
    return callback( this );
}

this way, when I have a connection or a transaction started by sql.begin i can pass the objet to a method that don't know if it's a transaction

Activity

  1. BeGj commented on Jan 6, 2025

    @BeGj

    @porsager Do you have any thoughts on this?

  2. BeGj commented on Jun 26, 2025

    @BeGj

    Bump @porsager

    Some times you want to be able to create functions that has a transaction in it. And sometimes this function is wrapped in a larger function which also makes a transaction. There are no errors on write time, but when running it then Runtime errors occurs. How can we solve this problem?

  3. vitaly-t commented on Sep 24, 2025

    @vitaly-t

    I did this within pg-promise, where sub-transactions are automatically handled as savepoints.

    @BeGj

  4. porsager commented on Oct 29, 2026

    @porsager
    Owner

    In v4, sql.begin inside a transaction runs in a savepoint, so code that opens a transaction works the same when given the pool or a transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions