Socket
Socket
Sign inDemoInstall

knex-schema-inspector

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knex-schema-inspector - npm Package Compare versions

Comparing version 1.6.1 to 1.6.2

32

dist/dialects/mssql.js

@@ -144,3 +144,3 @@ "use strict";

.select('TABLE_NAME', 'TABLE_SCHEMA', 'TABLE_CATALOG', 'TABLE_TYPE')
.from('information_schema.tables')
.from('INFORMATION_SCHEMA.TABLES')
.where({

@@ -186,3 +186,3 @@ TABLE_CATALOG: this.knex.client.database(),

.count({ count: '*' })
.from('information_schema.tables')
.from('INFORMATION_SCHEMA.TABLES')
.where({

@@ -277,15 +277,19 @@ TABLE_CATALOG: this.knex.client.database(),

return __awaiter(this, void 0, void 0, function () {
var count;
var result;
return __generator(this, function (_a) {
count = this.knex
.count({ count: '*' })
.from('information_schema.tables')
.where({
TABLE_CATALOG: this.knex.client.database(),
TABLE_NAME: table,
COLUMN_NAME: column,
TABLE_SCHEMA: this.schema,
})
.first().count;
return [2 /*return*/, !!count];
switch (_a.label) {
case 0: return [4 /*yield*/, this.knex
.count({ count: '*' })
.from('INFORMATION_SCHEMA.COLUMNS')
.where({
TABLE_CATALOG: this.knex.client.database(),
TABLE_NAME: table,
COLUMN_NAME: column,
TABLE_SCHEMA: this.schema,
})
.first()];
case 1:
result = _a.sent();
return [2 /*return*/, (result && result.count === 1) || false];
}
});

@@ -292,0 +296,0 @@ });

@@ -135,3 +135,3 @@ import { Knex } from 'knex';

.select('TABLE_NAME', 'TABLE_SCHEMA', 'TABLE_CATALOG', 'TABLE_TYPE')
.from('information_schema.tables')
.from('INFORMATION_SCHEMA.TABLES')
.where({

@@ -172,3 +172,3 @@ TABLE_CATALOG: this.knex.client.database(),

.count<{ count: 0 | 1 }>({ count: '*' })
.from('information_schema.tables')
.from('INFORMATION_SCHEMA.TABLES')
.where({

@@ -305,5 +305,5 @@ TABLE_CATALOG: this.knex.client.database(),

async hasColumn(table: string, column: string): Promise<boolean> {
const { count } = this.knex
const result = await this.knex
.count<{ count: 0 | 1 }>({ count: '*' })
.from('information_schema.tables')
.from('INFORMATION_SCHEMA.COLUMNS')
.where({

@@ -316,3 +316,4 @@ TABLE_CATALOG: this.knex.client.database(),

.first();
return !!count;
return (result && result.count === 1) || false;
}

@@ -319,0 +320,0 @@

{
"name": "knex-schema-inspector",
"version": "1.6.1",
"version": "1.6.2",
"description": "Utility for extracting information about existing DB schema",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -76,2 +76,10 @@ import knex, { Knex } from 'knex';

describe('.hasColumns', () => {
it('returns if table and column exists or not', async () => {
expect(await inspector.hasColumn('teams', 'credits')).to.equal(true);
expect(await inspector.hasColumn('teams', 'foobar')).to.equal(false);
expect(await inspector.hasColumn('foobar', 'foobar')).to.equal(false);
});
});
describe('.columns', () => {

@@ -78,0 +86,0 @@ it('returns information for all tables', async () => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc