Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gajus/slonik
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v33.3.0
Choose a base ref
...
head repository: gajus/slonik
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v33.3.1
Choose a head ref
  • 3 commits
  • 20 files changed
  • 1 contributor

Commits on Apr 19, 2023

  1. Copy the full SHA
    364946f View commit details

Commits on Apr 20, 2023

  1. fix: update dependencies

    gajus committed Apr 20, 2023
    Copy the full SHA
    1370ed9 View commit details
  2. test: remove invalid test

    gajus committed Apr 20, 2023
    Copy the full SHA
    d3374ae View commit details
7,907 changes: 4,713 additions & 3,194 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -12,45 +12,45 @@
"is-plain-object": "^5.0.0",
"iso8601-duration": "^1.3.0",
"p-defer": "^3.0.0",
"pg": "^8.9.0",
"pg-copy-streams": "^6.0.4",
"pg": "^8.10.0",
"pg-copy-streams": "^6.0.5",
"pg-copy-streams-binary": "^2.2.0",
"pg-cursor": "^2.8.0",
"pg-cursor": "^2.9.0",
"pg-protocol": "^1.6.0",
"pg-types": "^4.0.1",
"postgres-array": "^3.0.1",
"postgres-array": "^3.0.2",
"postgres-interval": "^4.0.0",
"roarr": "^7.14.1",
"safe-stable-stringify": "^2.4.1",
"roarr": "^7.15.0",
"safe-stable-stringify": "^2.4.3",
"serialize-error": "^8.0.0",
"through2": "^4.0.2"
},
"description": "A Node.js PostgreSQL client with strict types, detailed logging and assertions.",
"devDependencies": {
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/github": "^8.0.6",
"@semantic-release/npm": "^9.0.1",
"@semantic-release/github": "^8.0.7",
"@semantic-release/npm": "^10.0.3",
"@types/concat-stream": "^2.0.0",
"@types/pg-copy-streams": "^1.2.1",
"@types/sinon": "^10.0.13",
"@types/through2": "^2.0.36",
"ava": "^5.0.1",
"@types/pg-copy-streams": "^1.2.2",
"@types/sinon": "^10.0.14",
"@types/through2": "^2.0.38",
"ava": "^5.2.0",
"coveralls": "^3.1.1",
"delay": "^5.0.0",
"eslint": "^8.36.0",
"eslint-config-canonical": "^41.0.0",
"expect-type": "^0.14.2",
"eslint": "^8.38.0",
"eslint-config-canonical": "^41.0.3",
"expect-type": "^0.15.0",
"gitdown": "^3.1.5",
"husky": "^4.3.6",
"nyc": "^15.1.0",
"pg-native": "^3.0.1",
"postgres": "^3.2.4",
"postgres": "^3.3.4",
"postgres-bridge": "^1.14.0",
"semantic-release": "^19.0.5",
"sinon": "^14.0.0",
"semantic-release": "^21.0.1",
"sinon": "^15.0.4",
"ts-node": "^10.9.1",
"typescript": "^4.8.4",
"zod": "^3.19.1"
"typescript": "^5.0.4",
"zod": "^3.21.4"
},
"engines": {
"node": ">=10.0"
1 change: 0 additions & 1 deletion src/connectionMethods/many.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import { query } from './query';

/**
* Makes a query and expects at least 1 result.
*
* @throws NotFoundError If query returns no rows.
*/
export const many: InternalQueryMethod = async (
1 change: 0 additions & 1 deletion src/connectionMethods/maybeOne.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import { query } from './query';

/**
* Makes a query and expects exactly one result.
*
* @throws DataIntegrityError If query returns multiple rows.
*/
export const maybeOne: InternalQueryMethod = async (
1 change: 0 additions & 1 deletion src/connectionMethods/maybeOneFirst.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import { maybeOne } from './maybeOne';
/**
* Makes a query and expects exactly one result.
* Returns value of the first column.
*
* @throws DataIntegrityError If query returns multiple rows.
*/
export const maybeOneFirst: InternalQueryMethod = async (
1 change: 0 additions & 1 deletion src/connectionMethods/one.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import { query } from './query';

/**
* Makes a query and expects exactly one result.
*
* @throws NotFoundError If query returns no rows.
* @throws DataIntegrityError If query returns multiple rows.
*/
1 change: 0 additions & 1 deletion src/connectionMethods/oneFirst.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import { one } from './one';
/**
* Makes a query and expects exactly one result.
* Returns value of the first column.
*
* @throws NotFoundError If query returns no rows.
* @throws DataIntegrityError If query returns multiple rows.
*/
10 changes: 2 additions & 8 deletions src/connectionMethods/transaction.ts
Original file line number Diff line number Diff line change
@@ -38,20 +38,14 @@ const execTransaction: InternalTransactionFunction = async (
throw new BackendTerminatedError(poolClientState.terminated);
}

if (
poolClientState.mock === false &&
poolClientState.ignoreCommitAndRollback === false
) {
if (poolClientState.mock === false) {
await connection.query('COMMIT');
}

return result;
} catch (error) {
if (!poolClientState.terminated) {
if (
poolClientState.mock === false &&
poolClientState.ignoreCommitAndRollback === false
) {
if (poolClientState.mock === false) {
await connection.query('ROLLBACK');
}

1 change: 0 additions & 1 deletion src/factories/createClientConfiguration.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ export const createClientConfiguration = (
connectionTimeout: 5_000,
idleInTransactionSessionTimeout: 60_000,
idleTimeout: 5_000,
ignoreCommitAndRollback: false,
interceptors: [],
maximumPoolSize: 10,
queryRetryLimit: 5,
1 change: 0 additions & 1 deletion src/factories/createConnection.ts
Original file line number Diff line number Diff line change
@@ -97,7 +97,6 @@ export const createConnection = async (

poolClientStateMap.set(connection, {
connectionId: createUid(),
ignoreCommitAndRollback: poolState.ignoreCommitAndRollback,
mock: poolState.mock,
poolId: poolState.poolId,
terminated: null,
1 change: 0 additions & 1 deletion src/factories/createMockPool.ts
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@ export const createMockPool = (

poolStateMap.set(pool, {
ended: false,
ignoreCommitAndRollback: true,
mock: true,
poolId,
typeOverrides: null,
1 change: 0 additions & 1 deletion src/factories/createPool.ts
Original file line number Diff line number Diff line change
@@ -72,7 +72,6 @@ export const createPool = async (

poolStateMap.set(pool, {
ended: false,
ignoreCommitAndRollback: clientConfiguration.ignoreCommitAndRollback,
mock: false,
poolId,
typeOverrides: null,
2 changes: 0 additions & 2 deletions src/state.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import { type Pool as PgPool, type PoolClient as PgClientPool } from 'pg';

type PoolState = {
ended: boolean;
ignoreCommitAndRollback: boolean;
mock: boolean;
poolId: string;
typeOverrides: Promise<TypeOverrides> | null;
@@ -14,7 +13,6 @@ type PoolState = {
type PoolClientState = {
activeQuery?: DeferredPromise<unknown>;
connectionId: string;
ignoreCommitAndRollback: boolean;
mock: boolean;
poolId: string;
terminated: Error | null;
4 changes: 0 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -99,10 +99,6 @@ export type ClientConfiguration = {
* Timeout (in milliseconds) after which idle clients are closed. Use 'DISABLE_TIMEOUT' constant to disable the timeout. (Default: 5000)
*/
readonly idleTimeout: number | 'DISABLE_TIMEOUT';
/**
* Do not send COMMIT after successful transaction. (Default: false)
*/
readonly ignoreCommitAndRollback: boolean;
/**
* An array of [Slonik interceptors](https://github.com/gajus/slonik#slonik-interceptors).
*/
1 change: 0 additions & 1 deletion src/utilities/hasOwnProperty.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* A stricter type guard.
*
* @see https://tsplay.dev/WK8zGw
*/
export const hasOwnProperty = <X extends {}, Y extends PropertyKey>(
1 change: 0 additions & 1 deletion test/helpers/createClientConfiguration.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ export const createClientConfiguration = (): ClientConfiguration => {
connectionTimeout: 5_000,
idleInTransactionSessionTimeout: 60_000,
idleTimeout: 5_000,
ignoreCommitAndRollback: false,
interceptors: [],
maximumPoolSize: 10,
queryRetryLimit: 5,
2 changes: 0 additions & 2 deletions test/helpers/createPool.ts
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ export const createPool = async (

poolStateMap.set(internalPool, {
ended: false,
ignoreCommitAndRollback: false,
mock: false,
poolId: '1',
typeOverrides: null,
@@ -62,7 +61,6 @@ export const createPool = async (
connectionTimeout: 5_000,
idleInTransactionSessionTimeout: 5_000,
idleTimeout: 5_000,
ignoreCommitAndRollback: false,
interceptors: [],
maximumPoolSize: 1,
queryRetryLimit: 1,
1 change: 0 additions & 1 deletion test/slonik/factories/createClientConfiguration.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ const defaultConfiguration = {
connectionTimeout: 5_000,
idleInTransactionSessionTimeout: 60_000,
idleTimeout: 5_000,
ignoreCommitAndRollback: false,
interceptors: [],
maximumPoolSize: 10,
queryRetryLimit: 5,
23 changes: 0 additions & 23 deletions test/slonik/integration/pg.ts
Original file line number Diff line number Diff line change
@@ -9,29 +9,6 @@ const { test } = createTestRunner(PgPool, 'pg');

createIntegrationTests(test, PgPool);

test('does not break out of a transaction', async (t) => {
const pool = await createPool(t.context.dsn, {
ignoreCommitAndRollback: true,
PgPool,
});

await t.notThrowsAsync(
pool.connect(async (connection) => {
await connection.query(sql.unsafe`BEGIN`);
await connection.query(sql.unsafe`SAVEPOINT foo`);

await connection.transaction(async (transaction) => {
await transaction.query(sql.unsafe`SELECT 1`);
});

await connection.query(sql.unsafe`ROLLBACK TO SAVEPOINT foo`);
await connection.query(sql.unsafe`ROLLBACK`);
}),
);

await pool.end();
});

test('returns expected query result object (NOTICE)', async (t) => {
const pool = await createPool(t.context.dsn, {
PgPool,
2 changes: 0 additions & 2 deletions test/slonik/routines/executeQuery.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ beforeEach((t) => {

poolClientStateMap.set(t.context.connection, {
connectionId: '1',
ignoreCommitAndRollback: false,
mock: true,
poolId: '1',
terminated: null,
@@ -163,7 +162,6 @@ test('transaction errors are not handled if the function was called by a transac

poolClientStateMap.set(connection, {
connectionId: '1',
ignoreCommitAndRollback: false,
mock: true,
poolId: '1',
terminated: null,