Socket
Socket
Sign inDemoInstall

knex

Package Overview
Dependencies
Maintainers
5
Versions
252
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knex - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

lib/dialects/index.js

10

CONTRIBUTING.md

@@ -172,2 +172,12 @@ ## How to contribute to Knex.js

## Typescript source files
> TL;DR: Starting with release 2.0.0 Knex is adding support for Typescript source files. Thus to develop in this repo you will need to run `npm run build` each time you edit `.ts` files to generate the resulting `.js` files. This is automatically run whenever you run `npm install` or checkout a new Git branch so when developing in Javascript you don't have to worry about it. It is encouraged that new functionality and sources be written in Typescript but this is not required.
Starting with release 2.0.0, Knex is support source additions in Typescript! This allows for better safety in the code added. However, pre-2.0.0 Knex was always written in pure Javascript and thus a "hybrid" approach is being used for 2.0.0 to allow for the new `.ts` files to exist along `.js` files that make up the majority of this repository.
To develop in this repository use the `npm run build` and `npm run clean` commands to compile and delete the `.js` and related files from `.ts` files. If you wish to have the `tsc` compiled watch and recompile on changes then run `npm run build:ts -- --watch`. Note that for easy integration with Javascript the outputted files are done in a "side-by-side" manner meaning that `lib/foo/bar.ts` will result in `lib/foo/bar.js`. This is done automatically via the npm script command `"prepare"` whenever you run `npm install` and Git hook for `post-checkout` (added by Husky) which executes when you run commands like `git checkout` , thus making it easier to not have to worry about this if you're working in pure Javascript.
The script file `./scripts/update_gitignore_for_tsc_output.js` file is called as part of the `npm run build` command which will update the `lib/.gitignore` file which is used to ensure generated `.js` and related files from `tsc` compilation are not checked into the git repo.
## Want to be Collaborator?

@@ -174,0 +184,0 @@

11

lib/dialects/mssql/schema/mssql-compiler.js

@@ -52,6 +52,13 @@ // MySQL Schema Compiler

);
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 });
}

@@ -58,0 +65,0 @@

2

lib/dialects/mysql/query/mysql-querycompiler.js

@@ -134,3 +134,3 @@ // MySQL Query Compiler

columns[val.COLUMN_NAME] = {
defaultValue: val.COLUMN_DEFAULT,
defaultValue: val.COLUMN_DEFAULT === 'NULL' ? null : val.COLUMN_DEFAULT,
type: val.DATA_TYPE,

@@ -137,0 +137,0 @@ maxLength: val.CHARACTER_MAXIMUM_LENGTH,

@@ -51,4 +51,4 @@ // MySQL Schema Compiler

return (
this.client.wrapIdentifier(row.Field) ===
this.client.wrapIdentifier(column)
this.client.wrapIdentifier(row.Field.toLowerCase()) ===
this.client.wrapIdentifier(column.toLowerCase())
);

@@ -55,0 +55,0 @@ });

@@ -114,3 +114,4 @@ // Oracledb Client

} else if (value instanceof BlobHelper) {
return 'EMPTY_BLOB()';
formatter.bindings.push(value.value);
return '?';
}

@@ -117,0 +118,0 @@ return unwrapRaw(value, true, builder, this, formatter) || '?';

@@ -121,5 +121,5 @@ // PostgreSQL Schema Compiler

refreshMaterializedView(viewName) {
refreshMaterializedView(viewName, concurrently = false) {
this.pushQuery({
sql: `refresh materialized view ${this.formatter.wrap(viewName)}`,
sql: `refresh materialized view${concurrently ? " concurrently" : ""} ${this.formatter.wrap(viewName)}`,
});

@@ -126,0 +126,0 @@ }

@@ -5,3 +5,3 @@ const Client = require('../../client');

const parseConnection = require('./parse-connection');
const { resolveClientNameWithAliases } = require('../../util/helpers');
const { getDialectByNameOrAlias } = require('../../dialects');

@@ -38,4 +38,3 @@ function resolveConfig(config) {

const resolvedClientName = resolveClientNameWithAliases(clientName);
Dialect = require(`../../dialects/${resolvedClientName}/index.js`);
Dialect = getDialectByNameOrAlias(clientName);
}

@@ -42,0 +41,0 @@

@@ -8,2 +8,6 @@ const Client = require('../client');

const { resolveConfig } = require('./internal/config-resolver');
const SchemaBuilder = require('../schema/builder');
const ViewBuilder = require('../schema/viewbuilder');
const ColumnBuilder = require('../schema/columnbuilder');
const TableBuilder = require('../schema/tablebuilder');

@@ -32,2 +36,26 @@ function knex(config) {

knex.SchemaBuilder = {
extend: function (methodName, fn) {
SchemaBuilder.extend(methodName, fn);
},
};
knex.ViewBuilder = {
extend: function (methodName, fn) {
ViewBuilder.extend(methodName, fn);
},
};
knex.ColumnBuilder = {
extend: function (methodName, fn) {
ColumnBuilder.extend(methodName, fn);
},
};
knex.TableBuilder = {
extend: function (methodName, fn) {
TableBuilder.extend(methodName, fn);
},
};
module.exports = knex;

@@ -44,3 +44,3 @@ const path = require('path');

if (name[0] === '-') name = name.slice(1);
return yyyymmddhhmmss() + '_' + name + '.' + this.config.extension;
return yyyymmddhhmmss() + '_' + name + '.' + this.config.extension.split('-')[0];
}

@@ -47,0 +47,0 @@

const { EventEmitter } = require('events');
const toArray = require('lodash/toArray');
const assign = require('lodash/assign');
const { addQueryContext } = require('../util/helpers');

@@ -99,2 +100,13 @@ const saveAsyncStack = require('../util/save-async-stack');

SchemaBuilder.extend = (methodName, fn) => {
if (Object.prototype.hasOwnProperty.call(SchemaBuilder.prototype, methodName)) {
throw new Error(
`Can't extend SchemaBuilder with existing method ('${methodName}').`
);
}
assign(SchemaBuilder.prototype, { [methodName]: fn });
};
augmentWithBuilderInterface(SchemaBuilder);

@@ -101,0 +113,0 @@ addQueryContext(SchemaBuilder);

const extend = require('lodash/extend');
const assign = require('lodash/assign');
const toArray = require('lodash/toArray');

@@ -90,2 +91,13 @@ const { addQueryContext } = require('../util/helpers');

ColumnBuilder.extend = (methodName, fn) => {
if (Object.prototype.hasOwnProperty.call(ColumnBuilder.prototype, methodName)) {
throw new Error(
`Can't extend ColumnBuilder with existing method ('${methodName}').`
);
}
assign(ColumnBuilder.prototype, { [methodName]: fn });
};
const AlterMethods = {};

@@ -92,0 +104,0 @@

@@ -11,2 +11,3 @@ // TableBuilder

const extend = require('lodash/extend');
const assign = require('lodash/assign');
const toArray = require('lodash/toArray');

@@ -364,2 +365,13 @@ const helpers = require('../util/helpers');

TableBuilder.extend = (methodName, fn) => {
if (Object.prototype.hasOwnProperty.call(TableBuilder.prototype, methodName)) {
throw new Error(
`Can't extend TableBuilder with existing method ('${methodName}').`
);
}
assign(TableBuilder.prototype, { [methodName]: fn });
};
module.exports = TableBuilder;
const helpers = require('../util/helpers');
const extend = require('lodash/extend');
const assign = require('lodash/assign');

@@ -81,2 +82,13 @@ class ViewBuilder {

ViewBuilder.extend = (methodName, fn) => {
if (Object.prototype.hasOwnProperty.call(ViewBuilder.prototype, methodName)) {
throw new Error(
`Can't extend ViewBuilder with existing method ('${methodName}').`
);
}
assign(ViewBuilder.prototype, { [methodName]: fn });
};
module.exports = ViewBuilder;
{
"name": "knex",
"version": "2.0.0",
"version": "2.1.0",
"description": "A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3",

@@ -11,2 +11,6 @@ "main": "knex",

"scripts": {
"build": "npm run build:gitignore && npm run build:ts",
"clean": "node scripts/clean.js",
"build:ts": "tsc",
"build:gitignore": "node scripts/update_gitignore_for_tsc_output.js run",
"format": "prettier --write \"{lib,bin,scripts,test}/**/*.js\"",

@@ -56,3 +60,4 @@ "debug:test": "mocha --inspect-brk --exit -t 0 test/all-tests-suite.js",

"stress:destroy": "docker-compose -f scripts/stress-test/docker-compose.yml stop",
"prepare": "husky install"
"prepare": "husky install && npm run clean && npm run build",
"prepublishOnly": "npm run clean && npm run build"
},

@@ -100,7 +105,7 @@ "dependencies": {

"*.{js,json}": [
"prettier --write",
"git add"
"prettier --write"
]
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.1",
"@types/node": "^17.0.25",

@@ -119,7 +124,7 @@ "better-sqlite3": "^7.5.1",

"eslint-plugin-mocha-no-only": "^1.1.1",
"husky": "^7.0.4",
"husky": "^8.0.1",
"jake": "^10.8.5",
"JSONStream": "^1.3.5",
"lint-staged": "^12.3.7",
"mocha": "^9.2.2",
"mocha": "^10.0.0",
"mock-fs": "^5.1.2",

@@ -134,3 +139,3 @@ "mysql": "^2.18.1",

"rimraf": "^3.0.2",
"sinon": "^13.0.1",
"sinon": "^14.0.0",
"sinon-chai": "^3.7.0",

@@ -145,3 +150,3 @@ "source-map-support": "^0.5.21",

"tsd": "^0.20.0",
"typescript": "4.6.3"
"typescript": "4.7.2"
},

@@ -203,5 +208,5 @@ "buildDependencies": [

"browser": {
"./lib/migrate/Migrator.js": "./lib/util/noop.js",
"./lib/migrations/migrate/Migrator.js": "./lib/util/noop.js",
"./lib/bin/cli.js": "./lib/util/noop.js",
"./lib/seed/Seeder.js": "./lib/util/noop.js",
"./lib/migrations/seed/Seeder.js": "./lib/util/noop.js",
"tedious": false,

@@ -224,3 +229,8 @@ "mysql": false,

"bin/*",
"lib/*",
"lib/",
"lib/**/*.js",
"!lib/**/*.ts",
"!lib/**/*.d.ts",
"!lib/**/*.js.map",
"!lib/.gitignore",
"scripts/*",

@@ -227,0 +237,0 @@ "types/index.d.ts",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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