Socket
Socket
Sign inDemoInstall

knex

Package Overview
Dependencies
17
Maintainers
4
Versions
252
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.21.16 to 0.21.17

10

CHANGELOG.md
# Master (Unreleased)
# 0.21.17 - 30 January, 2021
### Bug fixes:
- SQLite: Fix SQLite foreign on delete when altering a table #4261
### New features:
- Add support for optimizer hints (see https://github.com/knex/documentation/pull/306 for documentation) #4243
# 0.21.16 - 17 January, 2021

@@ -4,0 +14,0 @@

3

lib/dialects/mssql/query/compiler.js

@@ -265,2 +265,3 @@ // MSSQL Query Compiler

const top = this.top();
const hints = this._hintComments()
const columns = this.grouped.columns || [];

@@ -289,3 +290,3 @@ let i = -1,

return (
`select ${distinctClause}` +
`select ${hints}${distinctClause}` +
(top ? top + ' ' : '') +

@@ -292,0 +293,0 @@ sql.join(', ') +

@@ -489,3 +489,3 @@ // SQLite3_DDL

if (foreignInfo.onDelete) {
newForeignSQL += ` ON DELETE ${foreignInfo.onUpdate}`;
newForeignSQL += ` ON DELETE ${foreignInfo.onDelete}`;
}

@@ -492,0 +492,0 @@

@@ -188,2 +188,21 @@ // Builder

// Adds a single hint or an array of hits to the list of "hintComments" on the query.
hintComment(hints) {
hints = Array.isArray(hints) ? hints : [hints]
if (hints.some((hint) => !isString(hint))) {
throw new Error('Hint comment must be a string');
}
if (hints.some((hint) => hint.includes('/*') || hint.includes('*/'))) {
throw new Error('Hint comment cannot include "/*" or "*/"');
}
if (hints.some((hint) => hint.includes('?'))) {
throw new Error('Hint comment cannot include "?"');
}
this._statements.push({
grouping: 'hintComments',
value: hints,
})
return this;
},
// Prepends the `schemaName` on `tableName` defined by `.table` and `.join`.

@@ -1068,3 +1087,3 @@ withSchema(schemaName) {

clear(statement) {
if (!['with', 'select', 'columns', 'where', 'union', 'join', 'group', 'order', 'having', 'limit', 'offset', 'counter', 'counters'].includes(statement))
if (!['with', 'select', 'columns', 'hintComments', 'where', 'union', 'join', 'group', 'order', 'having', 'limit', 'offset', 'counter', 'counters'].includes(statement))
throw new Error(`Knex Error: unknown statement '${statement}'`);

@@ -1071,0 +1090,0 @@ if (statement.startsWith('counter')) return this.clearCounters();

@@ -185,2 +185,9 @@ // Query Compiler

_hintComments() {
let hints = this.grouped.hintComments || [];
hints = hints.map((hint) => compact(hint.value).join(' '));
hints = compact(hints).join(' ');
return hints ? `/*+ ${hints} */ ` : ''
}
// Compiles the columns in the query, specifying if an item was distinct.

@@ -190,2 +197,3 @@ columns() {

if (this.onlyUnions()) return '';
const hints = this._hintComments()
const columns = this.grouped.columns || [];

@@ -213,3 +221,3 @@ let i = -1,

return (
`select ${distinctClause}` +
`select ${hints}${distinctClause}` +
sql.join(', ') +

@@ -216,0 +224,0 @@ (this.tableName

{
"name": "knex",
"version": "0.21.16",
"version": "0.21.17",
"description": "A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser",

@@ -5,0 +5,0 @@ "main": "knex.js",

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc