Repository: knex/knex
Pull request #5753 (2023-11-28 09:53:06)

Bump pg-connection-string from 2.6.1 to 2.6.2
Bumps [pg-connection-string](https://github.com/brianc/node-postgres/tree/HEAD/packages/pg-connection-string) from 2.6.1 to 2.6.2.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/brianc/node-postgres/commit/a2a355a6807bf75d92d7f0cb0f219588811a5356"><code>a2a355a</code></a> Publish</li>
<li><a href="https://github.com/brianc/node-postgres/commit/cf24ef28ee2134b63576afba341452f8adfb8a4d"><code>cf24ef2</code></a> pg-connection-string: avoid clobbering port from queryparams (<a href="https://github.com/brianc/node-postgres/tree/HEAD/packages/pg-connection-string/issues/2833">#2833</a>)</li>
<li>See full diff in <a href="https://github.com/brianc/node-postgres/commits/pg-connection-string@2.6.2/packages/pg-connection-string">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pg-connection-string&package-manager=npm_and_yarn&previous-version=2.6.1&new-version=2.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

coveralls: 
[![Coverage Status](https://coveralls.io/builds/64212638/badge)](https://coveralls.io/builds/64212638)

coverage: 92.799%. remained the same
when pulling **97142f48d052b4ca980e50afde63feb406fd0131 on dependabot/npm_and_yarn/pg-connection-string-2.6.2**
into **57419fbbea4af2103480cae920c977864945df60 on master**.


Patch:
diff --git a/lib/dialects/mysql/schema/mysql-tablecompiler.js b/lib/dialects/mysql/schema/mysql-tablecompiler.js
index ac192ee4..5438c9d6 100644
--- a/lib/dialects/mysql/schema/mysql-tablecompiler.js
+++ b/lib/dialects/mysql/schema/mysql-tablecompiler.js
@@ -160,6 +160,14 @@ class TableCompiler_MySQL extends TableCompiler {
             }
           });
         }
+        const bigIncrementsCols = this._getBigIncrementsColumnNames();
+        if (bigIncrementsCols.length) {
+          bigIncrementsCols.forEach((c) => {
+            if (!columns.includes(c)) {
+              columns.unshift(c);
+            }
+          });
+        }
       }
 
       return `,${constraintName} primary key (${this.formatter.columnize(
@@ -292,6 +300,7 @@ class TableCompiler_MySQL extends TableCompiler {
 
     const primaryCols = columns;
     let incrementsCols = [];
+    let bigIncrementsCols = [];
     if (this.grouped.columns) {
       incrementsCols = this._getIncrementsColumnNames();
       if (incrementsCols) {
@@ -301,6 +310,14 @@ class TableCompiler_MySQL extends TableCompiler {
           }
         });
       }
+      bigIncrementsCols = this._getBigIncrementsColumnNames();
+      if (bigIncrementsCols) {
+        bigIncrementsCols.forEach((c) => {
+          if (!primaryCols.includes(c)) {
+            primaryCols.unshift(c);
+          }
+        });
+      }
     }
     if (this.method !== 'create' && this.method !== 'createIfNot') {
       this.pushQuery(
@@ -316,6 +333,13 @@ class TableCompiler_MySQL extends TableCompiler {
         )} int unsigned not null auto_increment`
       );
     }
+    if (bigIncrementsCols.length) {
+      this.pushQuery(
+        `alter table ${this.tableName()} modify column ${this.formatter.columnize(
+          bigIncrementsCols
+        )} bigint unsigned not null auto_increment`
+      );
+    }
   }
 
   unique(columns, indexName) {
diff --git a/lib/dialects/postgres/index.js b/lib/dialects/postgres/index.js
index 6b577185..4a968da6 100644
--- a/lib/dialects/postgres/index.js
+++ b/lib/dialects/postgres/index.js
@@ -194,7 +194,9 @@ class Client_PG extends Client {
 
     return new Promise(function (resolver, rejecter) {
       const queryStream = connection.query(
-        new PGQueryStream(sql, obj.bindings, options)
+        new PGQueryStream(sql, obj.bindings, options), err => {
+          rejecter(err);
+        }
       );
 
       queryStream.on('error', function (error) {
diff --git a/lib/execution/transaction.js b/lib/execution/transaction.js
index 40532cfc..c5a60ce3 100644
--- a/lib/execution/transaction.js
+++ b/lib/execution/transaction.js
@@ -219,6 +219,10 @@ class Transaction extends EventEmitter {
           return makeTransactor(this, connection, trxClient);
         })
         .then((transactor) => {
+          this.transactor = transactor;
+          if (this.outerTx) {
+            transactor.parentTransaction = this.outerTx.transactor;
+          }
           transactor.executionPromise = executionPromise;
 
           // If we've returned a "thenable" from the transaction container, assume
diff --git a/lib/query/querybuilder.js b/lib/query/querybuilder.js
index 94dfa9f8..0d3cff51 100644
--- a/lib/query/querybuilder.js
+++ b/lib/query/querybuilder.js
@@ -1730,7 +1730,7 @@ Builder.prototype.andWhereRaw = Builder.prototype.whereRaw;
 Builder.prototype.andWhereBetween = Builder.prototype.whereBetween;
 Builder.prototype.andWhereNotBetween = Builder.prototype.whereNotBetween;
 Builder.prototype.andWhereJsonObject = Builder.prototype.whereJsonObject;
-Builder.prototype.andWhereNotJsonObject = Builder.prototype.whereJsonObject;
+Builder.prototype.andWhereNotJsonObject = Builder.prototype.whereNotJsonObject;
 Builder.prototype.andWhereJsonPath = Builder.prototype.whereJsonPath;
 Builder.prototype.andWhereLike = Builder.prototype.whereLike;
 Builder.prototype.andWhereILike = Builder.prototype.whereILike;
diff --git a/lib/schema/tablecompiler.js b/lib/schema/tablecompiler.js
index 02f4b23d..68d2d495 100644
--- a/lib/schema/tablecompiler.js
+++ b/lib/schema/tablecompiler.js
@@ -418,6 +418,12 @@ class TableCompiler {
       .filter((c) => c.builder._type === 'increments')
       .map((c) => c.builder._args[0]);
   }
+
+  _getBigIncrementsColumnNames() {
+    return this.grouped.columns
+      .filter((c) => c.builder._type === 'bigincrements')
+      .map((c) => c.builder._args[0]);
+  }
 }
 
 TableCompiler.prototype.pushQuery = pushQuery;
diff --git a/package.json b/package.json
index f9619bd1..8ba21389 100644
--- a/package.json
+++ b/package.json
@@ -71,7 +71,7 @@
     "getopts": "2.3.0",
     "interpret": "^2.2.0",
     "lodash": "^4.17.21",
-    "pg-connection-string": "2.6.1",
+    "pg-connection-string": "2.6.2",
     "rechoir": "^0.8.0",
     "resolve-from": "^5.0.0",
     "tarn": "^3.0.2",
@@ -140,7 +140,7 @@
     "sqlite3": "^5.0.11",
     "tap-spec": "^5.0.0",
     "tape": "^5.6.0",
-    "tedious": "^14.4.0",
+    "tedious": "^16.6.1",
     "toxiproxy-node-client": "^2.0.6",
     "ts-node": "^10.9.1",
     "tsd": "^0.28.1",
diff --git a/types/index.d.ts b/types/index.d.ts
index ff64a0d3..d191bd47 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -734,6 +734,8 @@ declare namespace Knex {
     orHavingNotIn: HavingRange<TRecord, TResult>;
     havingNull: HavingNull<TRecord, TResult>;
     havingNotNull: HavingNull<TRecord, TResult>;
+    orHavingNull: HavingNull<TRecord, TResult>;
+    orHavingNotNull: HavingNull<TRecord, TResult>;
 
     // Clear
     clearSelect(): QueryBuilder<
@@ -2321,6 +2323,7 @@ declare namespace Knex {
   interface Transaction<TRecord extends {} = any, TResult = any[]>
     extends Knex<TRecord, TResult> {
     executionPromise: Promise<TResult>;
+    parentTransaction?: Transaction;
     isCompleted: () => boolean;
 
     query<TRecord extends {} = any, TResult = void>(
@@ -3043,7 +3046,7 @@ declare namespace Knex {
     host?: string;
     connectionString?: string;
     keepAlive?: boolean;
-    stream?: stream.Duplex;
+    stream?: () => stream.Duplex | stream.Duplex | undefined;
     statement_timeout?: false | number;
     parseInputDatesAsUTC?: boolean;
     ssl?: boolean | ConnectionOptions;


Test patch:
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml
index 5971d98e..ffd05fe0 100644
--- a/.github/workflows/integration-tests.yml
+++ b/.github/workflows/integration-tests.yml
@@ -109,7 +109,7 @@ jobs:
     name: Test user experience
     strategy:
       matrix:
-        node-version: [18.x, 16.x]
+        node-version: [18.x]
         os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
     steps:
       - name: Checkout Repository
diff --git a/test-tsd/having.test-d.ts b/test-tsd/having.test-d.ts
index 5749afd3..8eb08562 100644
--- a/test-tsd/having.test-d.ts
+++ b/test-tsd/having.test-d.ts
@@ -12,10 +12,26 @@ const main = async () => {
       .havingNull('age')
   );
 
+  expectType<User[]>(
+    await knex<User>('users')
+      .groupBy('count')
+      .orderBy('name', 'desc')
+      .havingNull('age')
+      .orHavingNull('name')
+  );
+
+  expectType<User[]>(
+    await knex<User>('users')
+      .groupBy('count')
+      .orderBy('name', 'desc')
+      .havingNotNull('age')
+  );
+
   expectType<User[]>(
     await knex<User>('users')
       .groupBy('count')
       .orderBy('name', 'desc')
       .havingNotNull('age')
+      .orHavingNotNull('name')
   );
 };
diff --git a/test-tsd/pg-config.test-d.ts b/test-tsd/pg-config.test-d.ts
index 47c43f48..ff3d3197 100644
--- a/test-tsd/pg-config.test-d.ts
+++ b/test-tsd/pg-config.test-d.ts
@@ -11,7 +11,7 @@ expectAssignable<Knex.PgConnectionConfig>({
   host: '',
   connectionString: '',
   keepAlive: true,
-  stream: new stream.Duplex(),
+  stream: () => new stream.Duplex(),
   statement_timeout: false,
   parseInputDatesAsUTC: false,
   ssl: true,
diff --git a/test/integration/execution/transaction.js b/test/integration/execution/transaction.js
index 8524ef9b..a73c3329 100644
--- a/test/integration/execution/transaction.js
+++ b/test/integration/execution/transaction.js
@@ -810,5 +810,27 @@ module.exports = function (knex) {
         // closed it. (Ex: this was the case for OracleDB before fixing #3721)
       });
     });
+
+    it('exposes the parent transaction', async () => {
+      await knex.transaction(async (trx1) => {
+        expect(trx1.parentTransaction).to.equal(undefined);
+
+        await trx1.transaction(async (trx2) => {
+          expect(trx2.parentTransaction).to.equal(trx1);
+        });
+
+        await trx1.transaction(async (trx2) => {
+          expect(trx2.parentTransaction).to.equal(trx1);
+
+          await trx2.transaction(async (trx3) => {
+            expect(trx3.parentTransaction).to.equal(trx2);
+          });
+
+          await trx2.transaction(async (trx3) => {
+            expect(trx3.parentTransaction).to.equal(trx2);
+          });
+        });
+      });
+    });
   });
 };
diff --git a/test/unit/schema-builder/mysql.js b/test/unit/schema-builder/mysql.js
index 563a52a7..1ce2f41e 100644
--- a/test/unit/schema-builder/mysql.js
+++ b/test/unit/schema-builder/mysql.js
@@ -723,6 +723,25 @@ module.exports = function (dialect) {
       );
     });
 
+    it('test basic create table with composite key on big incrementing column + other', function () {
+      tableSql = client
+        .schemaBuilder()
+        .createTable('users', function (table) {
+          table.primary(['userId', 'name']);
+          table.bigincrements('userId');
+          table.string('name');
+        })
+        .toSQL();
+
+      equal(2, tableSql.length);
+      expect(tableSql[0].sql).to.equal(
+        'create table `users` (`userId` bigint unsigned not null, `name` varchar(255), primary key (`userId`, `name`))'
+      );
+      expect(tableSql[1].sql).to.equal(
+        'alter table `users` modify column `userId` bigint unsigned not null auto_increment'
+      );
+    });
+
     it('test adding column after another column', function () {
       tableSql = client
         .schemaBuilder()