Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slonik

Package Overview
Dependencies
Maintainers
1
Versions
395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slonik - npm Package Compare versions

Comparing version 37.5.0 to 37.6.0

dist/regexRules/slonikPlaceholderRegexRule.d.ts

3

dist/factories/createSqlTag.js

@@ -8,2 +8,3 @@ "use strict";

const escapeLiteralValue_1 = require("../utilities/escapeLiteralValue");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const isPrimitiveValueExpression_1 = require("../utilities/isPrimitiveValueExpression");

@@ -36,3 +37,3 @@ const isSqlToken_1 = require("../utilities/isSqlToken");

else if ((0, isPrimitiveValueExpression_1.isPrimitiveValueExpression)(token)) {
rawSql += '$' + String(parameterValues.length + 1);
rawSql += (0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(parameterValues.length + 1);
parameterValues.push(token);

@@ -39,0 +40,0 @@ }

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

t.deepEqual(query, {
sql: 'SELECT $1::"int4"[]',
sql: 'SELECT $slonik_1::"int4"[]',
type: tokens_1.FragmentToken,

@@ -24,3 +24,3 @@ values: [[]],

t.deepEqual(query, {
sql: 'SELECT $1::"int8"[]',
sql: 'SELECT $slonik_1::"int8"[]',
type: tokens_1.FragmentToken,

@@ -34,3 +34,3 @@ // eslint-disable-next-line unicorn/numeric-separators-style

t.deepEqual(query, {
sql: 'SELECT $1::"int4"[]',
sql: 'SELECT $slonik_1::"int4"[]',
type: tokens_1.FragmentToken,

@@ -43,3 +43,3 @@ values: [[1, 2, 3]],

t.deepEqual(query, {
sql: 'SELECT $1::"bytea"[]',
sql: 'SELECT $slonik_1::"bytea"[]',
type: tokens_1.FragmentToken,

@@ -52,3 +52,3 @@ values: [[Buffer.from('foo')]],

t.deepEqual(query, {
sql: 'SELECT $1, $2::"int4"[], $3',
sql: 'SELECT $slonik_1, $slonik_2::"int4"[], $slonik_3',
type: tokens_1.FragmentToken,

@@ -61,3 +61,3 @@ values: [1, [1, 2, 3], 3],

t.deepEqual(query, {
sql: 'SELECT $1::int[]',
sql: 'SELECT $slonik_1::int[]',
type: tokens_1.FragmentToken,

@@ -64,0 +64,0 @@ values: [[1, 2, 3]],

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

t.deepEqual(query, {
sql: 'SELECT $1::date',
sql: 'SELECT $slonik_1::date',
type: tokens_1.FragmentToken,

@@ -16,0 +16,0 @@ values: ['2022-08-19'],

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

t.deepEqual(query, {
sql: 'SELECT $1 FROM "bar"',
sql: 'SELECT $slonik_1 FROM "bar"',
type: tokens_1.FragmentToken,

@@ -25,3 +25,3 @@ values: ['foo'],

t.deepEqual(query, {
sql: 'SELECT $1 FROM "bar"."baz"',
sql: 'SELECT $slonik_1 FROM "bar"."baz"',
type: tokens_1.FragmentToken,

@@ -28,0 +28,0 @@ values: ['foo'],

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

t.deepEqual(query, {
sql: 'SELECT make_interval(years => $1, months => $2, weeks => $3, days => $4, hours => $5, mins => $6, secs => $7)',
sql: 'SELECT make_interval(years => $slonik_1, months => $slonik_2, weeks => $slonik_3, days => $slonik_4, hours => $slonik_5, mins => $slonik_6, secs => $slonik_7)',
type: tokens_1.FragmentToken,

@@ -32,0 +32,0 @@ values: [1, 2, 3, 4, 5, 6, 7],

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

t.deepEqual(query, {
sql: 'SELECT ($1, $2, $3)',
sql: 'SELECT ($slonik_1, $slonik_2, $slonik_3)',
type: tokens_1.FragmentToken,

@@ -30,3 +30,3 @@ values: [1, 2, 3],

t.deepEqual(query, {
sql: 'SELECT ($1, foo, $2)',
sql: 'SELECT ($slonik_1, foo, $slonik_2)',
type: tokens_1.FragmentToken,

@@ -39,3 +39,3 @@ values: [1, 3],

t.deepEqual(query, {
sql: 'SELECT $1, to_timestamp($2), $3, $4',
sql: 'SELECT $slonik_1, to_timestamp($slonik_2), $slonik_3, $slonik_4',
type: tokens_1.FragmentToken,

@@ -48,3 +48,3 @@ values: [1, 2, 3, 4],

t.deepEqual(query, {
sql: 'SELECT $1, $2, to_timestamp($3), $4, $5, $6',
sql: 'SELECT $slonik_1, $slonik_2, to_timestamp($slonik_3), $slonik_4, $slonik_5, $slonik_6',
type: tokens_1.FragmentToken,

@@ -57,3 +57,3 @@ values: [1, 1, 2, 3, 4, 3],

t.deepEqual(query, {
sql: 'SELECT $1, to_timestamp($2), $3, $4',
sql: 'SELECT $slonik_1, to_timestamp($slonik_2), $slonik_3, $slonik_4',
type: tokens_1.FragmentToken,

@@ -69,3 +69,3 @@ values: [1n, 2n, 3n, 4n],

t.deepEqual(query, {
sql: 'SELECT ($1, $2), ($3, $4)',
sql: 'SELECT ($slonik_1, $slonik_2), ($slonik_3, $slonik_4)',
type: tokens_1.FragmentToken,

@@ -79,3 +79,3 @@ values: [1, 2, 3, 4],

t.deepEqual(query, {
sql: 'SELECT ($1, $2)',
sql: 'SELECT ($slonik_1, $slonik_2)',
type: tokens_1.FragmentToken,

@@ -82,0 +82,0 @@ values: ['a', data],

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

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: tokens_1.FragmentToken,

@@ -28,3 +28,3 @@ values: ['{"foo":"bar"}'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: tokens_1.FragmentToken,

@@ -37,3 +37,3 @@ values: ['[{"foo":"bar"}]'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: tokens_1.FragmentToken,

@@ -46,3 +46,3 @@ values: ['null'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: tokens_1.FragmentToken,

@@ -55,3 +55,3 @@ values: ['"example string"'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: tokens_1.FragmentToken,

@@ -64,3 +64,3 @@ values: ['1234'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: tokens_1.FragmentToken,

@@ -89,3 +89,3 @@ values: ['true'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: tokens_1.FragmentToken,

@@ -92,0 +92,0 @@ values: ['{"foo":"bar"}'],

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

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: tokens_1.FragmentToken,

@@ -28,3 +28,3 @@ values: ['{"foo":"bar"}'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: tokens_1.FragmentToken,

@@ -37,3 +37,3 @@ values: ['[{"foo":"bar"}]'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: tokens_1.FragmentToken,

@@ -46,3 +46,3 @@ values: ['null'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: tokens_1.FragmentToken,

@@ -55,3 +55,3 @@ values: ['"example string"'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: tokens_1.FragmentToken,

@@ -64,3 +64,3 @@ values: ['1234'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: tokens_1.FragmentToken,

@@ -89,3 +89,3 @@ values: ['true'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: tokens_1.FragmentToken,

@@ -92,0 +92,0 @@ values: ['{"foo":"bar"}'],

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

t.deepEqual(query, {
sql: 'SELECT $1',
sql: 'SELECT $slonik_1',
type: tokens_1.FragmentToken,

@@ -38,3 +38,3 @@ values: ['foo'],

t.deepEqual(query, {
sql: 'SELECT $1, $2',
sql: 'SELECT $slonik_1, $slonik_2',
type: tokens_1.FragmentToken,

@@ -48,3 +48,3 @@ values: ['foo', 'bar'],

t.deepEqual(query1, {
sql: 'SELECT $1 FROM (SELECT $2 FROM bar)',
sql: 'SELECT $slonik_1 FROM (SELECT $slonik_2 FROM bar)',
type: tokens_1.FragmentToken,

@@ -51,0 +51,0 @@ values: ['baz', 'foo'],

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

t.deepEqual(query, {
sql: 'SELECT to_timestamp($1)',
sql: 'SELECT to_timestamp($slonik_1)',
type: tokens_1.FragmentToken,

@@ -16,0 +16,0 @@ values: ['1660879644.951'],

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

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::"int4"[], $2::"int4"[], $3::"int4"[])',
sql: 'SELECT * FROM unnest($slonik_1::"int4"[], $slonik_2::"int4"[], $slonik_3::"int4"[])',
type: tokens_1.FragmentToken,

@@ -32,3 +32,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::integer[], $2::integer[], $3::integer[])',
sql: 'SELECT * FROM unnest($slonik_1::integer[], $slonik_2::integer[], $slonik_3::integer[])',
type: tokens_1.FragmentToken,

@@ -51,3 +51,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT bar, baz FROM unnest($1::"foo"."int4"[], $2::"foo"."int4"[]) AS foo(bar, baz)',
sql: 'SELECT bar, baz FROM unnest($slonik_1::"foo"."int4"[], $slonik_2::"foo"."int4"[]) AS foo(bar, baz)',
type: tokens_1.FragmentToken,

@@ -66,3 +66,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::"int4"[], $2::"int4"[], $3::"int4"[])',
sql: 'SELECT * FROM unnest($slonik_1::"int4"[], $slonik_2::"int4"[], $slonik_3::"int4"[])',
type: tokens_1.FragmentToken,

@@ -82,3 +82,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::"int4"[], $2::"int4"[], $3::"int4"[])',
sql: 'SELECT * FROM unnest($slonik_1::"int4"[], $slonik_2::"int4"[], $slonik_3::"int4"[])',
type: tokens_1.FragmentToken,

@@ -95,3 +95,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::"int4"[][])',
sql: 'SELECT * FROM unnest($slonik_1::"int4"[][])',
type: tokens_1.FragmentToken,

@@ -98,0 +98,0 @@ values: [[[[1], [2], [3]]]],

@@ -69,3 +69,4 @@ "use strict";

const originalQuery = {
sql: query.sql,
// See comments in `formatSlonikPlaceholder` for more information.
sql: query.sql.replaceAll('$slonik_', '$'),
values: query.values,

@@ -72,0 +73,0 @@ };

@@ -7,2 +7,3 @@ "use strict";

const escapeIdentifier_1 = require("../utilities/escapeIdentifier");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const isPrimitiveValueExpression_1 = require("../utilities/isPrimitiveValueExpression");

@@ -27,3 +28,3 @@ const isSqlToken_1 = require("../utilities/isSqlToken");

placeholderIndex++;
let sql = '$' + String(placeholderIndex) + '::';
let sql = (0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(placeholderIndex) + '::';
if ((0, isSqlToken_1.isSqlToken)(token.memberType) &&

@@ -30,0 +31,0 @@ token.memberType.type === 'SLONIK_TOKEN_FRAGMENT') {

@@ -5,2 +5,3 @@ "use strict";

const errors_1 = require("../errors");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const createBinarySqlFragment = (token, greatestParameterPosition) => {

@@ -11,3 +12,3 @@ if (!Buffer.isBuffer(token.data)) {

return {
sql: '$' + String(greatestParameterPosition + 1),
sql: (0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(greatestParameterPosition + 1),
values: [token.data],

@@ -14,0 +15,0 @@ };

@@ -5,2 +5,3 @@ "use strict";

const errors_1 = require("../errors");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const createDateSqlFragment = (token, greatestParameterPosition) => {

@@ -11,3 +12,3 @@ if (!(token.date instanceof Date)) {

return {
sql: '$' + String(greatestParameterPosition + 1) + '::date',
sql: (0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(greatestParameterPosition + 1) + '::date',
values: [token.date.toISOString().slice(0, 10)],

@@ -14,0 +15,0 @@ };

@@ -5,2 +5,4 @@ "use strict";

const errors_1 = require("../errors");
const slonikPlaceholderRegexRule_1 = require("../regexRules/slonikPlaceholderRegexRule");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const createFragmentSqlFragment = (token, greatestParameterPosition) => {

@@ -10,3 +12,3 @@ let sql = '';

let greatestMatchedParameterPosition = 0;
sql += token.sql.replaceAll(/\$(\d+)/gu, (match, g1) => {
sql += token.sql.replaceAll(slonikPlaceholderRegexRule_1.slonikPlaceholderRegexRule, (match, g1) => {
const parameterPosition = Number.parseInt(g1, 10);

@@ -19,3 +21,3 @@ if (parameterPosition > greatestMatchedParameterPosition) {

}
return '$' + String(parameterPosition + greatestParameterPosition);
return (0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(parameterPosition + greatestParameterPosition);
});

@@ -22,0 +24,0 @@ if (greatestMatchedParameterPosition > token.values.length) {

@@ -5,2 +5,3 @@ "use strict";

const errors_1 = require("../errors");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const zod_1 = require("zod");

@@ -47,4 +48,4 @@ const IntervalInput = zod_1.z

intervalTokens.push(mappedToken +
' => $' +
String(greatestParameterPosition + values.length));
' => ' +
(0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(greatestParameterPosition + values.length));
}

@@ -51,0 +52,0 @@ }

@@ -6,2 +6,3 @@ "use strict";

const Logger_1 = require("../Logger");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const isPlainObject_1 = require("../utilities/isPlainObject");

@@ -42,4 +43,3 @@ const safeStringify_1 = require("../utilities/safeStringify");

return {
sql: '$' +
String(greatestParameterPosition + 1) +
sql: (0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(greatestParameterPosition + 1) +
'::' +

@@ -46,0 +46,0 @@ (binary ? 'jsonb' : 'json'),

@@ -7,2 +7,3 @@ "use strict";

const createSqlTokenSqlFragment_1 = require("../factories/createSqlTokenSqlFragment");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const isPrimitiveValueExpression_1 = require("../utilities/isPrimitiveValueExpression");

@@ -25,3 +26,3 @@ const isSqlToken_1 = require("../utilities/isSqlToken");

else if ((0, isPrimitiveValueExpression_1.isPrimitiveValueExpression)(member)) {
placeholders.push('$' + String(++placeholderIndex));
placeholders.push((0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(++placeholderIndex));
values.push(member);

@@ -28,0 +29,0 @@ }

@@ -5,2 +5,4 @@ "use strict";

const errors_1 = require("../errors");
const slonikPlaceholderRegexRule_1 = require("../regexRules/slonikPlaceholderRegexRule");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const createQuerySqlFragment = (token, greatestParameterPosition) => {

@@ -10,3 +12,3 @@ let sql = '';

let greatestMatchedParameterPosition = 0;
sql += token.sql.replaceAll(/\$(\d+)/gu, (match, g1) => {
sql += token.sql.replaceAll(slonikPlaceholderRegexRule_1.slonikPlaceholderRegexRule, (match, g1) => {
const parameterPosition = Number.parseInt(g1, 10);

@@ -19,3 +21,3 @@ if (parameterPosition > greatestMatchedParameterPosition) {

}
return '$' + String(parameterPosition + greatestParameterPosition);
return (0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(parameterPosition + greatestParameterPosition);
});

@@ -22,0 +24,0 @@ if (greatestMatchedParameterPosition > token.values.length) {

@@ -5,2 +5,3 @@ "use strict";

const errors_1 = require("../errors");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const createTimestampSqlFragment = (token, greatestParameterPosition) => {

@@ -11,3 +12,5 @@ if (!(token.date instanceof Date)) {

return {
sql: 'to_timestamp($' + String(greatestParameterPosition + 1) + ')',
sql: 'to_timestamp(' +
(0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(greatestParameterPosition + 1) +
')',
values: [String(token.date.getTime() / 1000)],

@@ -14,0 +17,0 @@ };

@@ -7,2 +7,3 @@ "use strict";

const escapeIdentifier_1 = require("../utilities/escapeIdentifier");
const formatSlonikPlaceholder_1 = require("../utilities/formatSlonikPlaceholder");
const isPrimitiveValueExpression_1 = require("../utilities/isPrimitiveValueExpression");

@@ -40,4 +41,3 @@ const stripArrayNotation_1 = require("../utilities/stripArrayNotation");

}
unnestSqlTokens.push('$' +
String(++placeholderIndex) +
unnestSqlTokens.push((0, formatSlonikPlaceholder_1.formatSlonikPlaceholder)(++placeholderIndex) +
'::' +

@@ -44,0 +44,0 @@ (columnTypeIsIdentifier

@@ -100,3 +100,3 @@ {

"types": "./dist/index.d.ts",
"version": "37.5.0"
"version": "37.6.0"
}

@@ -11,3 +11,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT $1::"int4"[]',
sql: 'SELECT $slonik_1::"int4"[]',
type: FragmentToken,

@@ -26,3 +26,3 @@ values: [[]],

t.deepEqual(query, {
sql: 'SELECT $1::"int8"[]',
sql: 'SELECT $slonik_1::"int8"[]',
type: FragmentToken,

@@ -38,3 +38,3 @@ // eslint-disable-next-line unicorn/numeric-separators-style

t.deepEqual(query, {
sql: 'SELECT $1::"int4"[]',
sql: 'SELECT $slonik_1::"int4"[]',
type: FragmentToken,

@@ -52,3 +52,3 @@ values: [[1, 2, 3]],

t.deepEqual(query, {
sql: 'SELECT $1::"bytea"[]',
sql: 'SELECT $slonik_1::"bytea"[]',
type: FragmentToken,

@@ -66,3 +66,3 @@ values: [[Buffer.from('foo')]],

t.deepEqual(query, {
sql: 'SELECT $1, $2::"int4"[], $3',
sql: 'SELECT $slonik_1, $slonik_2::"int4"[], $slonik_3',
type: FragmentToken,

@@ -80,3 +80,3 @@ values: [1, [1, 2, 3], 3],

t.deepEqual(query, {
sql: 'SELECT $1::int[]',
sql: 'SELECT $slonik_1::int[]',
type: FragmentToken,

@@ -83,0 +83,0 @@ values: [[1, 2, 3]],

@@ -13,3 +13,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT $1::date',
sql: 'SELECT $slonik_1::date',
type: FragmentToken,

@@ -16,0 +16,0 @@ values: ['2022-08-19'],

@@ -11,3 +11,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT $1 FROM "bar"',
sql: 'SELECT $slonik_1 FROM "bar"',
type: FragmentToken,

@@ -25,3 +25,3 @@ values: ['foo'],

t.deepEqual(query, {
sql: 'SELECT $1 FROM "bar"."baz"',
sql: 'SELECT $slonik_1 FROM "bar"."baz"',
type: FragmentToken,

@@ -28,0 +28,0 @@ values: ['foo'],

@@ -29,3 +29,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT make_interval(years => $1, months => $2, weeks => $3, days => $4, hours => $5, mins => $6, secs => $7)',
sql: 'SELECT make_interval(years => $slonik_1, months => $slonik_2, weeks => $slonik_3, days => $slonik_4, hours => $slonik_5, mins => $slonik_6, secs => $slonik_7)',
type: FragmentToken,

@@ -32,0 +32,0 @@ values: [1, 2, 3, 4, 5, 6, 7],

@@ -11,3 +11,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT ($1, $2, $3)',
sql: 'SELECT ($slonik_1, $slonik_2, $slonik_3)',
type: FragmentToken,

@@ -38,3 +38,3 @@ values: [1, 2, 3],

t.deepEqual(query, {
sql: 'SELECT ($1, foo, $2)',
sql: 'SELECT ($slonik_1, foo, $slonik_2)',
type: FragmentToken,

@@ -52,3 +52,3 @@ values: [1, 3],

t.deepEqual(query, {
sql: 'SELECT $1, to_timestamp($2), $3, $4',
sql: 'SELECT $slonik_1, to_timestamp($slonik_2), $slonik_3, $slonik_4',
type: FragmentToken,

@@ -66,3 +66,3 @@ values: [1, 2, 3, 4],

t.deepEqual(query, {
sql: 'SELECT $1, $2, to_timestamp($3), $4, $5, $6',
sql: 'SELECT $slonik_1, $slonik_2, to_timestamp($slonik_3), $slonik_4, $slonik_5, $slonik_6',
type: FragmentToken,

@@ -80,3 +80,3 @@ values: [1, 1, 2, 3, 4, 3],

t.deepEqual(query, {
sql: 'SELECT $1, to_timestamp($2), $3, $4',
sql: 'SELECT $slonik_1, to_timestamp($slonik_2), $slonik_3, $slonik_4',
type: FragmentToken,

@@ -97,3 +97,3 @@ values: [1n, 2n, 3n, 4n],

t.deepEqual(query, {
sql: 'SELECT ($1, $2), ($3, $4)',
sql: 'SELECT ($slonik_1, $slonik_2), ($slonik_3, $slonik_4)',
type: FragmentToken,

@@ -112,3 +112,3 @@ values: [1, 2, 3, 4],

t.deepEqual(query, {
sql: 'SELECT ($1, $2)',
sql: 'SELECT ($slonik_1, $slonik_2)',
type: FragmentToken,

@@ -115,0 +115,0 @@ values: ['a', data],

@@ -13,3 +13,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: FragmentToken,

@@ -28,3 +28,3 @@ values: ['{"foo":"bar"}'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: FragmentToken,

@@ -39,3 +39,3 @@ values: ['[{"foo":"bar"}]'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: FragmentToken,

@@ -50,3 +50,3 @@ values: ['null'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: FragmentToken,

@@ -61,3 +61,3 @@ values: ['"example string"'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: FragmentToken,

@@ -72,3 +72,3 @@ values: ['1234'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: FragmentToken,

@@ -108,3 +108,3 @@ values: ['true'],

t.deepEqual(query, {
sql: 'SELECT $1::json',
sql: 'SELECT $slonik_1::json',
type: FragmentToken,

@@ -111,0 +111,0 @@ values: ['{"foo":"bar"}'],

@@ -13,3 +13,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: FragmentToken,

@@ -28,3 +28,3 @@ values: ['{"foo":"bar"}'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: FragmentToken,

@@ -39,3 +39,3 @@ values: ['[{"foo":"bar"}]'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: FragmentToken,

@@ -50,3 +50,3 @@ values: ['null'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: FragmentToken,

@@ -61,3 +61,3 @@ values: ['"example string"'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: FragmentToken,

@@ -72,3 +72,3 @@ values: ['1234'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: FragmentToken,

@@ -108,3 +108,3 @@ values: ['true'],

t.deepEqual(query, {
sql: 'SELECT $1::jsonb',
sql: 'SELECT $slonik_1::jsonb',
type: FragmentToken,

@@ -111,0 +111,0 @@ values: ['{"foo":"bar"}'],

@@ -34,3 +34,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT $1',
sql: 'SELECT $slonik_1',
type: FragmentToken,

@@ -45,3 +45,3 @@ values: ['foo'],

t.deepEqual(query, {
sql: 'SELECT $1, $2',
sql: 'SELECT $slonik_1, $slonik_2',
type: FragmentToken,

@@ -57,3 +57,3 @@ values: ['foo', 'bar'],

t.deepEqual(query1, {
sql: 'SELECT $1 FROM (SELECT $2 FROM bar)',
sql: 'SELECT $slonik_1 FROM (SELECT $slonik_2 FROM bar)',
type: FragmentToken,

@@ -60,0 +60,0 @@ values: ['baz', 'foo'],

@@ -13,3 +13,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT to_timestamp($1)',
sql: 'SELECT to_timestamp($slonik_1)',
type: FragmentToken,

@@ -16,0 +16,0 @@ values: ['1660879644.951'],

@@ -17,3 +17,3 @@ import { FragmentToken } from '../../tokens';

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::"int4"[], $2::"int4"[], $3::"int4"[])',
sql: 'SELECT * FROM unnest($slonik_1::"int4"[], $slonik_2::"int4"[], $slonik_3::"int4"[])',
type: FragmentToken,

@@ -38,3 +38,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::integer[], $2::integer[], $3::integer[])',
sql: 'SELECT * FROM unnest($slonik_1::integer[], $slonik_2::integer[], $slonik_3::integer[])',
type: FragmentToken,

@@ -62,3 +62,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT bar, baz FROM unnest($1::"foo"."int4"[], $2::"foo"."int4"[]) AS foo(bar, baz)',
sql: 'SELECT bar, baz FROM unnest($slonik_1::"foo"."int4"[], $slonik_2::"foo"."int4"[]) AS foo(bar, baz)',
type: FragmentToken,

@@ -82,3 +82,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::"int4"[], $2::"int4"[], $3::"int4"[])',
sql: 'SELECT * FROM unnest($slonik_1::"int4"[], $slonik_2::"int4"[], $slonik_3::"int4"[])',
type: FragmentToken,

@@ -103,3 +103,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::"int4"[], $2::"int4"[], $3::"int4"[])',
sql: 'SELECT * FROM unnest($slonik_1::"int4"[], $slonik_2::"int4"[], $slonik_3::"int4"[])',
type: FragmentToken,

@@ -121,3 +121,3 @@ values: [

t.deepEqual(query, {
sql: 'SELECT * FROM unnest($1::"int4"[][])',
sql: 'SELECT * FROM unnest($slonik_1::"int4"[][])',
type: FragmentToken,

@@ -124,0 +124,0 @@ values: [[[[1], [2], [3]]]],

@@ -38,2 +38,3 @@ import { InvalidInputError } from '../errors';

import { escapeLiteralValue } from '../utilities/escapeLiteralValue';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';
import { isPrimitiveValueExpression } from '../utilities/isPrimitiveValueExpression';

@@ -82,3 +83,3 @@ import { isSqlToken } from '../utilities/isSqlToken';

} else if (isPrimitiveValueExpression(token)) {
rawSql += '$' + String(parameterValues.length + 1);
rawSql += formatSlonikPlaceholder(parameterValues.length + 1);

@@ -85,0 +86,0 @@ parameterValues.push(token);

@@ -162,3 +162,4 @@ import { TRANSACTION_ROLLBACK_ERROR_PREFIX } from '../constants';

const originalQuery = {
sql: query.sql,
// See comments in `formatSlonikPlaceholder` for more information.
sql: query.sql.replaceAll('$slonik_', '$'),
values: query.values,

@@ -165,0 +166,0 @@ };

@@ -5,2 +5,3 @@ import { InvalidInputError, UnexpectedStateError } from '../errors';

import { escapeIdentifier } from '../utilities/escapeIdentifier';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';
import { isPrimitiveValueExpression } from '../utilities/isPrimitiveValueExpression';

@@ -37,3 +38,3 @@ import { isSqlToken } from '../utilities/isSqlToken';

let sql = '$' + String(placeholderIndex) + '::';
let sql = formatSlonikPlaceholder(placeholderIndex) + '::';

@@ -40,0 +41,0 @@ if (

import { InvalidInputError } from '../errors';
import { type BinarySqlToken, type SqlFragment } from '../types';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';

@@ -13,5 +14,5 @@ export const createBinarySqlFragment = (

return {
sql: '$' + String(greatestParameterPosition + 1),
sql: formatSlonikPlaceholder(greatestParameterPosition + 1),
values: [token.data],
};
};
import { InvalidInputError } from '../errors';
import { type DateSqlToken, type SqlFragment } from '../types';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';

@@ -15,5 +16,5 @@ export const createDateSqlFragment = (

return {
sql: '$' + String(greatestParameterPosition + 1) + '::date',
sql: formatSlonikPlaceholder(greatestParameterPosition + 1) + '::date',
values: [token.date.toISOString().slice(0, 10)],
};
};
import { UnexpectedStateError } from '../errors';
import { slonikPlaceholderRegexRule } from '../regexRules/slonikPlaceholderRegexRule';
import { type FragmentSqlToken, type SqlFragment } from '../types';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';

@@ -13,3 +15,3 @@ export const createFragmentSqlFragment = (

sql += token.sql.replaceAll(/\$(\d+)/gu, (match, g1) => {
sql += token.sql.replaceAll(slonikPlaceholderRegexRule, (match, g1) => {
const parameterPosition = Number.parseInt(g1, 10);

@@ -25,3 +27,5 @@

return '$' + String(parameterPosition + greatestParameterPosition);
return formatSlonikPlaceholder(
parameterPosition + greatestParameterPosition,
);
});

@@ -28,0 +32,0 @@

import { InvalidInputError } from '../errors';
import { type IntervalSqlToken, type SqlFragment } from '../types';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';
import { z } from 'zod';

@@ -60,4 +61,4 @@

mappedToken +
' => $' +
String(greatestParameterPosition + values.length),
' => ' +
formatSlonikPlaceholder(greatestParameterPosition + values.length),
);

@@ -64,0 +65,0 @@ }

@@ -8,2 +8,3 @@ import { InvalidInputError } from '../errors';

} from '../types';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';
import { isPlainObject } from '../utilities/isPlainObject';

@@ -61,4 +62,3 @@ import { safeStringify } from '../utilities/safeStringify';

sql:
'$' +
String(greatestParameterPosition + 1) +
formatSlonikPlaceholder(greatestParameterPosition + 1) +
'::' +

@@ -65,0 +65,0 @@ (binary ? 'jsonb' : 'json'),

@@ -9,2 +9,3 @@ import { InvalidInputError } from '../errors';

} from '../types';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';
import { isPrimitiveValueExpression } from '../utilities/isPrimitiveValueExpression';

@@ -34,3 +35,3 @@ import { isSqlToken } from '../utilities/isSqlToken';

} else if (isPrimitiveValueExpression(member)) {
placeholders.push('$' + String(++placeholderIndex));
placeholders.push(formatSlonikPlaceholder(++placeholderIndex));

@@ -37,0 +38,0 @@ values.push(member);

import { UnexpectedStateError } from '../errors';
import { slonikPlaceholderRegexRule } from '../regexRules/slonikPlaceholderRegexRule';
import { type QuerySqlToken, type SqlFragment } from '../types';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';

@@ -13,3 +15,3 @@ export const createQuerySqlFragment = (

sql += token.sql.replaceAll(/\$(\d+)/gu, (match, g1) => {
sql += token.sql.replaceAll(slonikPlaceholderRegexRule, (match, g1) => {
const parameterPosition = Number.parseInt(g1, 10);

@@ -25,3 +27,5 @@

return '$' + String(parameterPosition + greatestParameterPosition);
return formatSlonikPlaceholder(
parameterPosition + greatestParameterPosition,
);
});

@@ -28,0 +32,0 @@

import { InvalidInputError } from '../errors';
import { type SqlFragment, type TimestampSqlToken } from '../types';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';

@@ -15,5 +16,8 @@ export const createTimestampSqlFragment = (

return {
sql: 'to_timestamp($' + String(greatestParameterPosition + 1) + ')',
sql:
'to_timestamp(' +
formatSlonikPlaceholder(greatestParameterPosition + 1) +
')',
values: [String(token.date.getTime() / 1_000)],
};
};

@@ -9,2 +9,3 @@ import { InvalidInputError } from '../errors';

import { escapeIdentifier } from '../utilities/escapeIdentifier';
import { formatSlonikPlaceholder } from '../utilities/formatSlonikPlaceholder';
import { isPrimitiveValueExpression } from '../utilities/isPrimitiveValueExpression';

@@ -56,4 +57,3 @@ import { stripArrayNotation } from '../utilities/stripArrayNotation';

unnestSqlTokens.push(
'$' +
String(++placeholderIndex) +
formatSlonikPlaceholder(++placeholderIndex) +
'::' +

@@ -60,0 +60,0 @@ (columnTypeIsIdentifier

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

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

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

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

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

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 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