Skip to content

skeet70/node-postgres-transaction-repro

Repository files navigation

Transaction Behavour

This is a minimal reproduction of undocumented behaviour in node-postgres. It seems like running a query with ; separating statements (such as a SQL read in from disk to be run) results in the driver (or postgres itself, not sure) wrapping that query in a transaction block implicitly. This causes statements that cannot be run in a transaction block (such as CREATE DATABASE) to error.

The workaround is parsing the file into individual statements, and running each of those manually. I expected this behaviour to be documented in the node-postgres transactions docs (either that it does this implicit transaction, or some postgres setting does).

Requirements

  • docker
  • nodejs + yarn
  • python

there's a flake.nix providing ^ for Nix users

Install node modules with:

yarn

Running

Run the tests with:

yarn start

Note one test passes and one test fails, the difference between them being split statement queries vs one query with ;.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published