sails: Connection error when using PostgreSQL transactions
Sails version: 1.1.0 Node version: 8.10.0 NPM version: 4.6.1 DB adapter name: sails-postgresql DB adapter version: 1.0.1 Operating system: Windows 10
I am getting the following error when using the transactions given in an example:
“sendNativeQuery failed (“badConnection”). The provided connection is not valid or no longer active. Are you sure it was obtained by calling this driver’s getConnection() method?”
I’m using the following code:
await sails.getDatastore()
.transaction(async (db) => {
const createdEntity = await Entity.create({ name: 'test' }).usingConnection(db);
const foundEntity = await Entity.findOne({ id: createdEntity.id }).usingConnection(db);
})
The call to findOne fails with the above message. Is there a known issue with PostgreSQL transactions?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 21 (10 by maintainers)
Hm, I’m sure you guys put some thought into it already, but is there a way for transactions to work without having issues when transforming the code?