Repository: knex/knex
Pull request #5754 (2023-11-28 09:59:59)

Bump tedious from 14.7.0 to 16.6.1
Bumps [tedious](https://github.com/tediousjs/tedious) from 14.7.0 to 16.6.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/tediousjs/tedious/releases">tedious's releases</a>.</em></p>
<blockquote>
<h2>v16.6.1</h2>
<h2><a href="https://github.com/tediousjs/tedious/compare/v16.6.0...v16.6.1">16.6.1</a> (2023-11-19)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>add Node.js v20 support by bumping <code>@azure/identity</code> to <code>v3.4.1</code> (<a href="https://redirect.github.com/tediousjs/tedious/issues/1575">#1575</a>) (<a href="https://github.com/tediousjs/tedious/commit/57998f2a335c8b45d9e738862d5457a8edb54151">57998f2</a>)</li>
</ul>
<h2>v16.6.0</h2>
<h1><a href="https://github.com/tediousjs/tedious/compare/v16.5.0...v16.6.0">16.6.0</a> (2023-10-21)</h1>
<h3>Features</h3>
<ul>
<li>improve performance of response data parsing (<a href="https://redirect.github.com/tediousjs/tedious/issues/1580">#1580</a>) (<a href="https://github.com/tediousjs/tedious/commit/78a453055fd5c4268a104a72cda86dccca459533">78a4530</a>)</li>
</ul>
<h2>v16.5.0</h2>
<h1><a href="https://github.com/tediousjs/tedious/compare/v16.4.1...v16.5.0">16.5.0</a> (2023-10-10)</h1>
<h3>Features</h3>
<ul>
<li>improve performance on Node.js 16 by disabling class property definitions (<a href="https://redirect.github.com/tediousjs/tedious/issues/1581">#1581</a>) (<a href="https://github.com/tediousjs/tedious/commit/443701f35da3bbc4469bdce3168dae28362324a8">443701f</a>)</li>
</ul>
<h2>v16.4.1</h2>
<h2><a href="https://github.com/tediousjs/tedious/compare/v16.4.0...v16.4.1">16.4.1</a> (2023-09-17)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>handle timeouts during tls negotiation for <code>strict</code> encryption (<a href="https://redirect.github.com/tediousjs/tedious/issues/1564">#1564</a>) (<a href="https://github.com/tediousjs/tedious/commit/8c7e440c19211f8ce42c8fd5f4fb0622917fb9e9">8c7e440</a>)</li>
</ul>
<h2>v16.4.0</h2>
<h1><a href="https://github.com/tediousjs/tedious/compare/v16.3.0...v16.4.0">16.4.0</a> (2023-07-20)</h1>
<h3>Features</h3>
<ul>
<li>add redirect info to connection errors (<a href="https://redirect.github.com/tediousjs/tedious/issues/1527">#1527</a>) (<a href="https://github.com/tediousjs/tedious/commit/b78df149fd55d11125a35af7e2366c0a36ed4c74">b78df14</a>)</li>
</ul>
<h2>v16.3.0</h2>
<h1><a href="https://github.com/tediousjs/tedious/compare/v16.2.0...v16.3.0">16.3.0</a> (2023-07-20)</h1>
<h3>Features</h3>
<ul>
<li>add TDS8.0 Support for tedious (<a href="https://redirect.github.com/tediousjs/tedious/issues/1522">#1522</a>) (<a href="https://github.com/tediousjs/tedious/commit/c02e30f0fefe549dd5128eabf21b1f031a679005">c02e30f</a>)</li>
</ul>
<h2>v16.2.0</h2>
<h1><a href="https://github.com/tediousjs/tedious/compare/v16.1.0...v16.2.0">16.2.0</a> (2023-07-02)</h1>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/tediousjs/tedious/commit/57998f2a335c8b45d9e738862d5457a8edb54151"><code>57998f2</code></a> fix: add Node.js v20 support by bumping <code>@azure/identity</code> to <code>v3.4.1</code> (<a href="https://redirect.github.com/tediousjs/tedious/issues/1575">#1575</a>)</li>
<li><a href="https://github.com/tediousjs/tedious/commit/d26df9b232fbbdf4d32a8f4611a4672728b9f879"><code>d26df9b</code></a> docs: fix various typos (<a href="https://redirect.github.com/tediousjs/tedious/issues/1589">#1589</a>)</li>
<li><a href="https://github.com/tediousjs/tedious/commit/78a453055fd5c4268a104a72cda86dccca459533"><code>78a4530</code></a> feat: improve performance of response data parsing (<a href="https://redirect.github.com/tediousjs/tedious/issues/1580">#1580</a>)</li>
<li><a href="https://github.com/tediousjs/tedious/commit/443701f35da3bbc4469bdce3168dae28362324a8"><code>443701f</code></a> feat: improve performance on Node.js 16 by disabling class property definitio...</li>
<li><a href="https://github.com/tediousjs/tedious/commit/f4d91f173fab0669d45ae513922585f748c11022"><code>f4d91f1</code></a> chore: fix benchmark files (<a href="https://redirect.github.com/tediousjs/tedious/issues/1578">#1578</a>)</li>
<li><a href="https://github.com/tediousjs/tedious/commit/8c7e440c19211f8ce42c8fd5f4fb0622917fb9e9"><code>8c7e440</code></a> fix: handle timeouts during tls negotiation for <code>strict</code> encryption (<a href="https://redirect.github.com/tediousjs/tedious/issues/1564">#1564</a>)</li>
<li><a href="https://github.com/tediousjs/tedious/commit/4f3e2109128a5291675aba5f73a0b56aa8016d2f"><code>4f3e210</code></a> test: allow easier test debugging via <code>TEDIOUS_DEBUG</code> env variable (<a href="https://redirect.github.com/tediousjs/tedious/issues/1567">#1567</a>)</li>
<li><a href="https://github.com/tediousjs/tedious/commit/0f105c6f97c5de34c79eb36f6a88b6f3a832e250"><code>0f105c6</code></a> chore: replace <code>isolatedModules</code> with <code>verbatimModuleSyntax</code> (<a href="https://redirect.github.com/tediousjs/tedious/issues/1555">#1555</a>)</li>
<li><a href="https://github.com/tediousjs/tedious/commit/2b275313a3f5244c9a91a725aa239e8d4ac11275"><code>2b27531</code></a> test: fix TDS 8.0 test cases not being executed correctly (<a href="https://redirect.github.com/tediousjs/tedious/issues/1565">#1565</a>)</li>
<li><a href="https://github.com/tediousjs/tedious/commit/b78df149fd55d11125a35af7e2366c0a36ed4c74"><code>b78df14</code></a> feat: add redirect info to connection errors (<a href="https://redirect.github.com/tediousjs/tedious/issues/1527">#1527</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/tediousjs/tedious/compare/v14.7.0...v16.6.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tedious&package-manager=npm_and_yarn&previous-version=14.7.0&new-version=16.6.1)](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/64212810/badge)](https://coveralls.io/builds/64212810)

coverage: 92.799%. remained the same
when pulling **ff82856df9533de951a20e2540e1eb8a19e8b9cd on dependabot/npm_and_yarn/tedious-16.6.1**
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..dc252bd3 100644
--- a/package.json
+++ b/package.json
@@ -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/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/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()