Comparing version 12.0.0 to 12.0.1
@@ -22,3 +22,3 @@ "use strict"; | ||
const logContext = Symbol('LOG_CONTEXT'); | ||
const logContext = Symbol('LOG_INTERCEPTOR_CONTEXT'); | ||
@@ -25,0 +25,0 @@ const createLogInterceptor = () => { |
@@ -19,3 +19,3 @@ "use strict"; | ||
if (configuration && configuration.stripComments !== false) { | ||
if (!configuration || configuration.stripComments !== false) { | ||
sql = (0, _utilities.stripComments)(query.sql); | ||
@@ -22,0 +22,0 @@ } |
@@ -34,4 +34,41 @@ "use strict"; | ||
continue; | ||
} else if (Array.isArray(value) && Array.isArray(value[0])) { | ||
const valueSets = []; | ||
let placeholderIndex = bindings.length; | ||
let valueSetListSize = value.length; | ||
while (valueSetListSize--) { | ||
const placeholders = []; | ||
let setSize = value[0].length; | ||
while (setSize--) { | ||
placeholders.push('$' + ++placeholderIndex); | ||
} | ||
valueSets.push('(' + placeholders.join(', ') + ')'); | ||
} | ||
raw += valueSets.join(', '); | ||
for (const set of value) { | ||
if (!Array.isArray(set)) { | ||
throw new TypeError('Unexpected state.'); | ||
} | ||
bindings.push(...set); | ||
} // SELECT ?, [[1,1]]; SELECT ($1, $2) | ||
} else if (Array.isArray(value)) { | ||
const placeholders = []; | ||
let placeholderIndex = bindings.length; | ||
let setSize = value.length; | ||
while (setSize--) { | ||
placeholders.push('$' + ++placeholderIndex); | ||
} | ||
raw += '(' + placeholders.join(', ') + ')'; | ||
bindings.push(...value); | ||
} else { | ||
raw += '?'; | ||
raw += '$' + (bindings.length + 1); | ||
bindings.push(value); | ||
@@ -38,0 +75,0 @@ } |
@@ -95,3 +95,3 @@ { | ||
}, | ||
"version": "12.0.0" | ||
"version": "12.0.1" | ||
} |
@@ -20,2 +20,3 @@ <a name="slonik"></a> | ||
* [SQL injection guarding](#slonik-value-placeholders-tagged-template-literals). | ||
* [Set interpolation](#set-interpolation). | ||
* Detail [logging](#slonik-debugging). | ||
@@ -53,4 +54,3 @@ * [Parsing and logging of the auto_explain logs.](#logging-auto_explain). | ||
* [Tagged template literals](#slonik-value-placeholders-tagged-template-literals) | ||
* [Sets](#slonik-value-placeholders-sets) | ||
* [Multiple value sets](#slonik-value-placeholders-multiple-value-sets) | ||
* [Set interpolation](#slonik-value-placeholders-set-interpolation) | ||
* [Query methods](#slonik-query-methods) | ||
@@ -557,4 +557,4 @@ * [`any`](#slonik-query-methods-any) | ||
<a name="slonik-value-placeholders-sets"></a> | ||
### Sets | ||
<a name="slonik-value-placeholders-set-interpolation"></a> | ||
### Set interpolation | ||
@@ -577,5 +577,2 @@ Array expressions produce sets, e.g. | ||
<a name="slonik-value-placeholders-multiple-value-sets"></a> | ||
### Multiple value sets | ||
An array containing array expressions produce a collection of sets, e.g. | ||
@@ -600,3 +597,3 @@ | ||
<a name="slonik-value-placeholders-multiple-value-sets-creating-dynamic-delimited-identifiers"></a> | ||
<a name="slonik-value-placeholders-set-interpolation-creating-dynamic-delimited-identifiers"></a> | ||
#### Creating dynamic delimited identifiers | ||
@@ -613,3 +610,3 @@ | ||
// { | ||
// sql: 'SELECT ? FROM "bar"."baz"', | ||
// sql: 'SELECT $1 FROM "bar"."baz"', | ||
// values: [ | ||
@@ -622,3 +619,3 @@ // 'foo' | ||
<a name="slonik-value-placeholders-multiple-value-sets-inlining-dynamic-raw-sql"></a> | ||
<a name="slonik-value-placeholders-set-interpolation-inlining-dynamic-raw-sql"></a> | ||
#### Inlining dynamic/ raw SQL | ||
@@ -635,3 +632,3 @@ | ||
// { | ||
// sql: 'SELECT ? FROM "bar"', | ||
// sql: 'SELECT $1 FROM "bar"', | ||
// values: [ | ||
@@ -638,0 +635,0 @@ // 'foo' |
@@ -19,3 +19,3 @@ // @flow | ||
const logContext = Symbol('LOG_CONTEXT'); | ||
const logContext = Symbol('LOG_INTERCEPTOR_CONTEXT'); | ||
@@ -22,0 +22,0 @@ export default (): InterceptorType => { |
@@ -22,3 +22,3 @@ // @flow | ||
if (configuration && configuration.stripComments !== false) { | ||
if (!configuration || configuration.stripComments !== false) { | ||
sql = stripComments(query.sql); | ||
@@ -25,0 +25,0 @@ } |
@@ -43,4 +43,48 @@ // @flow | ||
continue; | ||
} else if (Array.isArray(value) && Array.isArray(value[0])) { | ||
const valueSets = []; | ||
let placeholderIndex = bindings.length; | ||
let valueSetListSize = value.length; | ||
while (valueSetListSize--) { | ||
const placeholders = []; | ||
let setSize = value[0].length; | ||
while (setSize--) { | ||
placeholders.push('$' + ++placeholderIndex); | ||
} | ||
valueSets.push('(' + placeholders.join(', ') + ')'); | ||
} | ||
raw += valueSets.join(', '); | ||
for (const set of value) { | ||
if (!Array.isArray(set)) { | ||
throw new TypeError('Unexpected state.'); | ||
} | ||
bindings.push(...set); | ||
} | ||
// SELECT ?, [[1,1]]; SELECT ($1, $2) | ||
} else if (Array.isArray(value)) { | ||
const placeholders = []; | ||
let placeholderIndex = bindings.length; | ||
let setSize = value.length; | ||
while (setSize--) { | ||
placeholders.push('$' + ++placeholderIndex); | ||
} | ||
raw += '(' + placeholders.join(', ') + ')'; | ||
bindings.push(...value); | ||
} else { | ||
raw += '?'; | ||
raw += '$' + (bindings.length + 1); | ||
@@ -47,0 +91,0 @@ bindings.push(value); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
228601
2460
993