Repository: knex/knex
Pull request #5169 (2022-05-09 09:10:50)

Bump sinon from 13.0.2 to 14.0.0
Bumps [sinon](https://github.com/sinonjs/sinon) from 13.0.2 to 14.0.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/sinonjs/sinon/blob/main/docs/changelog.md">sinon's changelog</a>.</em></p>
<blockquote>
<h2>14.0.0</h2>
<ul>
<li><a href="https://github.com/sinonjs/sinon/commit/c2bbd82641444eb5b32822489ae40f185afbbf00"><code>c2bbd826</code></a>
Drop node 12 (Morgan Roderick)
<blockquote>
<p>And embrace Node 18</p>
<p>See <a href="https://nodejs.org/en/about/releases/">https://nodejs.org/en/about/releases/</a></p>
</blockquote>
</li>
</ul>
<p><em>Released by Morgan Roderick on 2022-05-07.</em></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/sinonjs/sinon/commit/242b4292683a74faebc48c985129bee21643fb2c"><code>242b429</code></a> 14.0.0</li>
<li><a href="https://github.com/sinonjs/sinon/commit/c2bbd82641444eb5b32822489ae40f185afbbf00"><code>c2bbd82</code></a> Drop node 12</li>
<li>See full diff in <a href="https://github.com/sinonjs/sinon/compare/v13.0.2...v14.0.0">compare view</a></li>
</ul>
</details>
<br />


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

Coverage remained the same at 92.282% when pulling **e04bdbc24a0989195111df8dbb15b8afad274474 on dependabot/npm_and_yarn/sinon-14.0.0** into **e2516cd058df984410c113cafdd8808b3ca97cc7 on master**.

OlivierCavadenti: @dependabot rebase

Patch:
diff --git a/lib/dialects/mssql/schema/mssql-compiler.js b/lib/dialects/mssql/schema/mssql-compiler.js
index 6491f871..135222af 100644
--- a/lib/dialects/mssql/schema/mssql-compiler.js
+++ b/lib/dialects/mssql/schema/mssql-compiler.js
@@ -49,10 +49,17 @@ class SchemaCompiler_MSSQL extends SchemaCompiler {
       this.builder,
       this.bindingsHolder
     );
-    const sql =
+    const bindings = [tableName];
+    let sql =
       `SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES ` +
       `WHERE TABLE_NAME = ${formattedTable}`;
-    this.pushQuery({ sql, output: (resp) => resp.length > 0 });
+
+    if (this.schema) {
+      sql += ' AND TABLE_SCHEMA = ?';
+      bindings.push(this.schema);
+    }
+
+    this.pushQuery({ sql, bindings, output: (resp) => resp.length > 0 });
   }
 
   // Check whether a column exists on the schema.
diff --git a/package.json b/package.json
index 62f63deb..f57c4904 100644
--- a/package.json
+++ b/package.json
@@ -131,7 +131,7 @@
     "pg-query-stream": "^4.2.1",
     "prettier": "2.6.2",
     "rimraf": "^3.0.2",
-    "sinon": "^13.0.1",
+    "sinon": "^14.0.0",
     "sinon-chai": "^3.7.0",
     "source-map-support": "^0.5.21",
     "sqlite3": "^5.0.4",
diff --git a/types/index.d.ts b/types/index.d.ts
index 98bed908..3b8ac2f3 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -2607,17 +2607,28 @@ export declare namespace Knex {
   interface PgConnectionConfig {
     user?: string;
     database?: string;
-    password?: string;
+    password?: string | (() => string | Promise<string>);
     port?: number;
     host?: string;
     connectionString?: string;
     keepAlive?: boolean;
     stream?: stream.Duplex;
     statement_timeout?: false | number;
-    connectionTimeoutMillis?: number;
-    keepAliveInitialDelayMillis?: number;
+    parseInputDatesAsUTC?: boolean;
     ssl?: boolean | ConnectionOptions;
+    query_timeout?: number;
+    keepAliveInitialDelayMillis?: number;
+    idle_in_transaction_session_timeout?: number;
     application_name?: string;
+    connectionTimeoutMillis?: number;
+    types?: PgCustomTypesConfig;
+    options?: string;
+  }
+
+  type PgGetTypeParser = (oid: number, format: string) => any;
+
+  interface PgCustomTypesConfig {
+      getTypeParser: PgGetTypeParser;
   }
 
   type RedshiftConnectionConfig = PgConnectionConfig;


Test patch:
diff --git a/test/integration2/schema/misc.spec.js b/test/integration2/schema/misc.spec.js
index 3f754faa..0a7dfceb 100644
--- a/test/integration2/schema/misc.spec.js
+++ b/test/integration2/schema/misc.spec.js
@@ -1597,7 +1597,7 @@ describe('Schema (misc)', () => {
       });
 
       describe('hasTable', () => {
-        it('checks whether a table exists', () =>
+        it('should be true if a table exists', () =>
           knex.schema.hasTable('test_table_two').then((resp) => {
             expect(resp).to.equal(true);
           }));
@@ -1663,7 +1663,7 @@ describe('Schema (misc)', () => {
 
           describe('sqlite and mysql only', () => {
             it('checks whether a column exists without being case sensitive, resolving with a boolean', async function () {
-              if (!isSQLite(knex)&& !isMysql(knex)) {
+              if (!isSQLite(knex) && !isMysql(knex)) {
                 return this.skip();
               }
 
@@ -2046,7 +2046,7 @@ describe('Schema (misc)', () => {
 
       describe('withSchema', () => {
         describe('mssql only', () => {
-          if (!knex || !knex.client || !/mssql/i.test(knex.client.dialect)) {
+          if (!isMssql(knex)) {
             return Promise.resolve(true);
           }
 
@@ -2085,10 +2085,13 @@ describe('Schema (misc)', () => {
           }
 
           const defaultSchemaName = 'public';
-          const testSchemaName = 'test';
+          const testSchemaName = 'test_schema';
 
           before(() => createSchema(testSchemaName));
 
+          afterEach(() =>
+            knex.schema.withSchema(testSchemaName).dropTableIfExists('test')
+          );
           after(() => knex.schema.raw('DROP SCHEMA ' + testSchemaName));
 
           it('should not find non-existent tables', () =>
@@ -2096,6 +2099,11 @@ describe('Schema (misc)', () => {
               checkTable(defaultSchemaName, 'test', false)
             ));
 
+          it('should find existent tables', () =>
+            createTable(testSchemaName, 'test').then(() =>
+              checkTable(testSchemaName, 'test', true)
+            ));
+
           it('should create and drop tables', () =>
             createTable(testSchemaName, 'test')
               .then(() => checkColumn(testSchemaName, 'test'))
diff --git a/test/unit/schema-builder/mssql.js b/test/unit/schema-builder/mssql.js
index 87f85669..d33200f9 100644
--- a/test/unit/schema-builder/mssql.js
+++ b/test/unit/schema-builder/mssql.js
@@ -511,9 +511,9 @@ describe('MSSQL SchemaBuilder', function () {
 
     equal(1, tableSql.length);
     expect(tableSql[0].sql).to.equal(
-      'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ?'
+      'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?'
     );
-    expect(tableSql[0].bindings[0]).to.equal('schema.users');
+    expect(tableSql[0].bindings[0]).to.equal('users');
   });
 
   it('test rename table with schema', function () {