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: v29.2.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: v30.0.0
Choose a head ref
  • 2 commits
  • 51 files changed
  • 1 contributor

Commits on Aug 4, 2022

  1. Copy the full SHA
    9f620f9 View commit details

Commits on Aug 5, 2022

  1. feat: initialize type parsers when constructing Pool (#370)

    BREAKING CHANGE: now createPool needs to be awaited
    gajus authored Aug 5, 2022
    Copy the full SHA
    65e5791 View commit details
Showing with 549 additions and 370 deletions.
  1. +2 −2 .README/INTERCEPTORS.md
  2. +2 −2 .README/RECIPES.md
  3. +6 −6 .README/USAGE.md
  4. +10 −10 README.md
  5. +1 −1 benchmark/clients/slonik.js
  6. +191 −16 package-lock.json
  7. +1 −0 package.json
  8. +36 −48 src/binders/bindPoolConnection.ts
  9. +33 −44 src/binders/bindTransactionConnection.ts
  10. +2 −2 src/connectionMethods/any.ts
  11. +2 −2 src/connectionMethods/anyFirst.ts
  12. +2 −4 src/connectionMethods/copyFromBinary.ts
  13. +12 −2 src/connectionMethods/exists.ts
  14. +2 −2 src/connectionMethods/many.ts
  15. +2 −2 src/connectionMethods/manyFirst.ts
  16. +2 −2 src/connectionMethods/maybeOne.ts
  17. +2 −3 src/connectionMethods/maybeOneFirst.ts
  18. +2 −2 src/connectionMethods/one.ts
  19. +2 −3 src/connectionMethods/oneFirst.ts
  20. +2 −4 src/connectionMethods/query.ts
  21. +2 −3 src/connectionMethods/stream.ts
  22. +0 −18 src/factories/createConnection.ts
  23. +21 −3 src/factories/createPool.ts
  24. +23 −16 src/routines/createTypeOverrides.ts
  25. +6 −2 src/routines/executeQuery.ts
  26. +3 −6 src/types.ts
  27. +21 −13 test/dts.ts
  28. +35 −35 test/helpers/createIntegrationTests.ts
  29. +1 −1 test/helpers/createPool.ts
  30. +12 −12 test/slonik/binders/bindPool/connect.ts
  31. +4 −4 test/slonik/binders/bindPool/interceptors/afterPoolConnection.ts
  32. +1 −1 test/slonik/binders/bindPool/interceptors/beforePoolConnection.ts
  33. +8 −8 test/slonik/binders/bindPool/transaction.ts
  34. +3 −3 test/slonik/connectionMethods/anyFirst.ts
  35. +2 −2 test/slonik/connectionMethods/many.ts
  36. +3 −3 test/slonik/connectionMethods/manyFirst.ts
  37. +3 −3 test/slonik/connectionMethods/maybeOne.ts
  38. +4 −4 test/slonik/connectionMethods/maybeOneFirst.ts
  39. +6 −6 test/slonik/connectionMethods/nestedTransaction.ts
  40. +3 −3 test/slonik/connectionMethods/one.ts
  41. +4 −4 test/slonik/connectionMethods/oneFirst.ts
  42. +2 −2 test/slonik/connectionMethods/query/interceptors/beforeQueryExecution.ts
  43. +1 −1 test/slonik/connectionMethods/query/interceptors/transformQuery.ts
  44. +1 −1 test/slonik/connectionMethods/query/interceptors/transformRow.ts
  45. +9 −9 test/slonik/connectionMethods/query/query.ts
  46. +6 −6 test/slonik/connectionMethods/transaction.ts
  47. +0 −22 test/slonik/factories/createPool.ts
  48. +6 −6 test/slonik/integration/pg.ts
  49. +21 −5 test/slonik/routines/createTypeOverrides.ts
  50. +23 −10 test/slonik/routines/executeQuery.ts
  51. +1 −1 test/types.ts
4 changes: 2 additions & 2 deletions .README/INTERCEPTORS.md
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import {

const interceptors = [];

const connection = createPool('postgres://', {
const connection = await createPool('postgres://', {
interceptors
});

@@ -80,7 +80,7 @@ type Interceptor = {
Executed after a connection is acquired from the connection pool (or a new connection is created), e.g.
```js
const pool = createPool('postgres://');
const pool = await createPool('postgres://');

// Interceptor is executed here. ↓
pool.connect();
4 changes: 2 additions & 2 deletions .README/RECIPES.md
Original file line number Diff line number Diff line change
@@ -53,8 +53,8 @@ Inserting data this way ensures that the query is stable and reduces the amount
If connection is initiated by a query (as opposed to a obtained explicitly using `pool#connect()`), then `beforePoolConnection` interceptor can be used to change the pool that will be used to execute the query, e.g.

```js
const slavePool = createPool('postgres://slave');
const masterPool = createPool('postgres://master', {
const slavePool = await createPool('postgres://slave');
const masterPool = await createPool('postgres://master', {
interceptors: [
{
beforePoolConnection: (connectionContext, pool) => {
12 changes: 6 additions & 6 deletions .README/USAGE.md
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ import {
createPool,
} from 'slonik';

const pool = createPool('postgres://');
const pool = await createPool('postgres://');

```

@@ -78,7 +78,7 @@ import {
sql,
} from 'slonik';

const pool = createPool('postgres://');
const pool = await createPool('postgres://');

const main = async () => {
await pool.query(sql`
@@ -104,7 +104,7 @@ import {
sql,
} from 'slonik';

const pool = createPool('postgres://');
const pool = await createPool('postgres://');

const main = async () => {
pool.getPoolState();
@@ -205,7 +205,7 @@ import {
createPool
} from 'slonik';

const pool = createPool('postgres://');
const pool = await createPool('postgres://');

await pool.query(sql`SELECT 1`);

@@ -284,7 +284,7 @@ import {
createPool,
} from 'slonik';

const pool = createPool('postgres://localhost');
const pool = await createPool('postgres://localhost');

const result = await pool.connect(async (connection) => {
await connection.query(sql`SELECT 1`);
@@ -399,7 +399,7 @@ import { createPool } from 'slonik';

const PostgresBridge = createPostgresBridge(postgres);

const pool = createPool('postgres://', {
const pool = await createPool('postgres://', {
PgPool: PostgresBridge,
});

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -464,7 +464,7 @@ import {
createPool,
} from 'slonik';

const pool = createPool('postgres://');
const pool = await createPool('postgres://');

```

@@ -504,7 +504,7 @@ import {
sql,
} from 'slonik';

const pool = createPool('postgres://');
const pool = await createPool('postgres://');

const main = async () => {
await pool.query(sql`
@@ -532,7 +532,7 @@ import {
sql,
} from 'slonik';

const pool = createPool('postgres://');
const pool = await createPool('postgres://');

const main = async () => {
pool.getPoolState();
@@ -635,7 +635,7 @@ import {
createPool
} from 'slonik';

const pool = createPool('postgres://');
const pool = await createPool('postgres://');

await pool.query(sql`SELECT 1`);

@@ -726,7 +726,7 @@ import {
createPool,
} from 'slonik';

const pool = createPool('postgres://localhost');
const pool = await createPool('postgres://localhost');

const result = await pool.connect(async (connection) => {
await connection.query(sql`SELECT 1`);
@@ -851,7 +851,7 @@ import { createPool } from 'slonik';

const PostgresBridge = createPostgresBridge(postgres);

const pool = createPool('postgres://', {
const pool = await createPool('postgres://', {
PgPool: PostgresBridge,
});

@@ -946,7 +946,7 @@ import {

const interceptors = [];

const connection = createPool('postgres://', {
const connection = await createPool('postgres://', {
interceptors
});

@@ -1019,7 +1019,7 @@ type Interceptor = {
Executed after a connection is acquired from the connection pool (or a new connection is created), e.g.
```js
const pool = createPool('postgres://');
const pool = await createPool('postgres://');

// Interceptor is executed here. ↓
pool.connect();
@@ -1181,8 +1181,8 @@ Inserting data this way ensures that the query is stable and reduces the amount
If connection is initiated by a query (as opposed to a obtained explicitly using `pool#connect()`), then `beforePoolConnection` interceptor can be used to change the pool that will be used to execute the query, e.g.
```js
const slavePool = createPool('postgres://slave');
const masterPool = createPool('postgres://master', {
const slavePool = await createPool('postgres://slave');
const masterPool = await createPool('postgres://master', {
interceptors: [
{
beforePoolConnection: (connectionContext, pool) => {
2 changes: 1 addition & 1 deletion benchmark/clients/slonik.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ const {
sql,
} = require('slonik');

const pool = createPool('postgres://postgres@127.0.0.1:5432', {
const pool = await createPool('postgres://postgres@127.0.0.1:5432', {
captureStackTrace: false,
});

Loading