@contember/database
Advanced tools
Comparing version 2.0.0-alpha.32 to 2.0.0-alpha.34
@@ -34,3 +34,3 @@ import { ImplementationException } from "../exceptions.js"; | ||
__publicField(this, "createdAt", Date.now()); | ||
__publicField(this, "timerId"); | ||
__publicField(this, "timerId", null); | ||
} | ||
@@ -37,0 +37,0 @@ } |
@@ -34,3 +34,3 @@ import { ImplementationException } from "../exceptions.js"; | ||
__publicField(this, "createdAt", Date.now()); | ||
__publicField(this, "timerId"); | ||
__publicField(this, "timerId", null); | ||
} | ||
@@ -37,0 +37,0 @@ } |
@@ -74,3 +74,3 @@ import { ClientError, DatabaseError } from './errors'; | ||
createdAt: number; | ||
timerId: NodeJS.Timeout | undefined; | ||
timerId: ReturnType<typeof setTimeout> | null; | ||
constructor(client: PgClient); | ||
@@ -77,0 +77,0 @@ } |
{ | ||
"name": "@contember/database", | ||
"version": "2.0.0-alpha.32", | ||
"version": "2.0.0-alpha.34", | ||
"license": "Apache-2.0", | ||
@@ -26,6 +26,6 @@ "main": "./dist/production/index.js", | ||
"dependencies": { | ||
"@contember/queryable": "2.0.0-alpha.32" | ||
"@contember/queryable": "2.0.0-alpha.34" | ||
}, | ||
"devDependencies": { | ||
"@contember/database-tester": "2.0.0-alpha.32", | ||
"@contember/database-tester": "2.0.0-alpha.34", | ||
"@types/node": "^20.16.11", | ||
@@ -38,2 +38,2 @@ "pg": "^8.12.0" | ||
"type": "module" | ||
} | ||
} |
@@ -84,3 +84,3 @@ import { ImplementationException } from '../exceptions' | ||
public createdAt = Date.now() | ||
public timerId: NodeJS.Timeout | undefined | ||
public timerId: ReturnType<typeof setTimeout> | null = null | ||
@@ -87,0 +87,0 @@ constructor( |
@@ -1,2 +0,2 @@ | ||
import { expect, it } from 'vitest' | ||
import { expect, it } from 'bun:test' | ||
import { MutexDeadlockError } from '../../../src/utils' | ||
@@ -151,5 +151,5 @@ import { createConnectionMockAlt } from './createConnectionMockAlt' | ||
await expect(async () => await connection.scope(async c1 => c1.scope(async () => await c1.query('SELECT 1')))).rejects.toThrow(MutexDeadlockError) | ||
await expect(connection.scope(async c1 => c1.scope(async () => await c1.query('SELECT 1')))).rejects.toThrow(MutexDeadlockError) | ||
end() | ||
}) | ||
import { Connection, Pool } from '../../../src' | ||
import { PgClient } from '../../../src/client/PgClient' | ||
import EventEmitter from 'node:events' | ||
import { expect } from 'vitest' | ||
import { expect } from 'bun:test' | ||
@@ -21,3 +21,3 @@ export const createConnectionMockAlt = (...queries: { sql: string; timeout?: number; result?: any }[][]): [Connection, () => void] => { | ||
expect(query).toBeDefined() | ||
expect(sql).toEqual(query?.sql) | ||
expect(sql).toEqual(query?.sql as string) | ||
await new Promise<void>(resolve => setTimeout(resolve, query?.timeout ?? 1)) | ||
@@ -29,3 +29,3 @@ | ||
assertEmpty() { | ||
expect(queriesSet).deep.eq([]) | ||
expect(queriesSet).toStrictEqual([]) | ||
} | ||
@@ -32,0 +32,0 @@ }) |
import { EventManager } from '../../../src' | ||
import { assert, test } from 'vitest' | ||
import { expect, test } from 'bun:test' | ||
import { createConnectionMockAlt } from './createConnectionMockAlt' | ||
@@ -17,3 +17,3 @@ | ||
await connection.query('SELECT 2') | ||
assert.deepStrictEqual(events, [ | ||
expect(events).toStrictEqual([ | ||
{ sql: 'SELECT 1', source: 'client' }, | ||
@@ -47,3 +47,3 @@ { sql: 'SELECT 1', source: 'connection' }, | ||
await connection.query('SELECT 3') | ||
assert.deepStrictEqual(events, [ | ||
expect(events).toStrictEqual([ | ||
{ sql: 'BEGIN', source: 'client' }, | ||
@@ -82,3 +82,3 @@ { sql: 'BEGIN', source: 'connection' }, | ||
await connection.query('SELECT 3') | ||
assert.deepStrictEqual(events, [ | ||
expect(events).toStrictEqual([ | ||
{ sql: 'SELECT 1', source: 'scoped' }, | ||
@@ -123,3 +123,3 @@ { sql: 'SELECT 1', source: 'client' }, | ||
await connection.query('SELECT 4') | ||
assert.deepStrictEqual(events, [ | ||
expect(events).toStrictEqual([ | ||
{ sql: 'BEGIN', source: 'client' }, | ||
@@ -126,0 +126,0 @@ { sql: 'BEGIN', source: 'connection' }, |
@@ -1,2 +0,2 @@ | ||
import { expect, it, beforeAll } from 'vitest' | ||
import { expect, it, beforeAll } from 'bun:test' | ||
import { ClientErrorCodes, Pool, PoolLogger } from '../../../src' | ||
@@ -8,6 +8,6 @@ import { Client as PgClient } from 'pg' | ||
const logger: PoolLogger & {messages: string; clear: () => void} = (message, pool) => { | ||
logger.messages += `${pool.connecting}${pool.active}${pool.idle} ${pool.pending}: ${message}\n` | ||
logger.messages += `\t\t${pool.connecting}${pool.active}${pool.idle} ${pool.pending}: ${message}\n` | ||
} | ||
logger.messages = '\nCAI P\n' | ||
logger.clear = () => logger.messages = 'CAI P\n' | ||
logger.messages = '\n\t\tCAI P\n' | ||
logger.clear = () => logger.messages = '\n\t\tCAI P\n' | ||
return logger | ||
@@ -18,8 +18,2 @@ } | ||
beforeAll(() => { | ||
expect.addSnapshotSerializer({ | ||
test: val => typeof val === 'string', | ||
print: val => String(val), | ||
}) | ||
}) | ||
@@ -35,3 +29,3 @@ it('acquires and releases new connection from pool', async () => { | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -45,3 +39,3 @@ 000 1: Item added to a queue. | ||
001 0: Connection is idle and available. | ||
`) | ||
`) | ||
}) | ||
@@ -60,3 +54,3 @@ | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -70,3 +64,3 @@ 000 1: Item added to a queue. | ||
000 0: Too many idle connections, connection disposed. | ||
`) | ||
`) | ||
}) | ||
@@ -84,3 +78,3 @@ | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -95,3 +89,3 @@ 000 1: Item added to a queue. | ||
000 0: Connection has reached max age or usage and was disposed. | ||
`) | ||
`) | ||
}) | ||
@@ -109,3 +103,3 @@ | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -120,3 +114,3 @@ 000 1: Item added to a queue. | ||
000 0: Connection errored and was disposed. | ||
`) | ||
`) | ||
}) | ||
@@ -134,6 +128,6 @@ | ||
}) | ||
await expect(pool.acquire.bind(pool)).rejects.toThrowError('Failed to acquire a connection') | ||
await expect(pool.acquire()).rejects.toThrowError('Failed to acquire a connection') | ||
await timeout(4) | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -146,3 +140,3 @@ 000 1: Item added to a queue. | ||
001 0: Not connecting, queue is empty. | ||
`) | ||
`) | ||
}) | ||
@@ -163,3 +157,3 @@ | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -169,3 +163,3 @@ 010 0: Item fulfilled with an idle connection. | ||
001 0: Connection is idle and available. | ||
`) | ||
`) | ||
}) | ||
@@ -184,3 +178,3 @@ | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -201,3 +195,3 @@ 000 1: Item added to a queue. | ||
002 0: Connection is idle and available. | ||
`) | ||
`) | ||
}) | ||
@@ -216,3 +210,3 @@ | ||
await timeout(4) | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -227,3 +221,3 @@ 000 1: Item added to a queue. | ||
000 0: Idle connection disposed after timeout. | ||
`) | ||
`) | ||
}) | ||
@@ -246,3 +240,3 @@ | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -260,3 +254,3 @@ 000 1: Item added to a queue. | ||
001 0: Connection is idle and available. | ||
`) | ||
`) | ||
}) | ||
@@ -278,3 +272,3 @@ | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -294,3 +288,3 @@ 000 1: Item added to a queue. | ||
010 0: Not connecting, queue is empty. | ||
`) | ||
`) | ||
}) | ||
@@ -312,5 +306,5 @@ | ||
pgClientMock.connections.push(createRecoverableErrorPromise(), createRecoverableErrorPromise()) | ||
await expect(async () => await pool.acquire()).rejects.toThrowError('Failed to acquire a connection. Last error: too many connection') | ||
await expect(pool.acquire()).rejects.toThrowError('Failed to acquire a connection. Last error: too many connection') | ||
await timeout(20) | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -328,3 +322,3 @@ 000 1: Item added to a queue. | ||
000 0: Not connecting, queue is empty. | ||
`) | ||
`) | ||
}) | ||
@@ -342,5 +336,5 @@ | ||
pgClientMock.connections.push(createErrorPromise()) | ||
await expect(async () => await pool.acquire()).rejects.toThrowError('Database client connection error: my err') | ||
await expect(pool.acquire()).rejects.toThrowError('Database client connection error: my err') | ||
await timeout() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -351,3 +345,3 @@ 000 1: Item added to a queue. | ||
000 0: Connecting failed, rejecting pending item | ||
`) | ||
`) | ||
}) | ||
@@ -403,3 +397,3 @@ | ||
const conn3 = await pool.acquire() | ||
expect(logger.messages).toMatchInlineSnapshot(` | ||
expect(logger.messages).toEqual(` | ||
CAI P | ||
@@ -425,3 +419,3 @@ 000 1: Item added to a queue. | ||
010 0: Not connecting, queue is empty. | ||
`) | ||
`) | ||
}) |
import { Client, ConflictActionType, EventManager, LimitByGroupWrapper, LockType, Operator } from '../../../src' | ||
import { createConnectionMock } from '@contember/database-tester' | ||
import { SQL } from '../../src/tags' | ||
import { test } from 'vitest' | ||
import { test } from 'bun:test' | ||
@@ -6,0 +6,0 @@ interface Test { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1684220
18213
- Removed@contember/queryable@2.0.0-alpha.32(transitive)