New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dbgate-query-splitter

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dbgate-query-splitter - npm Package Compare versions

Comparing version 4.3.0 to 4.3.1

17

lib/index.js
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./splitQuery"));
__export(require("./options"));
__exportStar(require("./splitQuery"), exports);
__exportStar(require("./options"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.noSplitSplitterOptions = exports.sqliteSplitterOptions = exports.postgreSplitterOptions = exports.mssqlSplitterOptions = exports.mysqlSplitterOptions = exports.defaultSplitterOptions = void 0;
exports.defaultSplitterOptions = {

@@ -4,0 +5,0 @@ stringsBegins: ["'"],

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.splitQuery = void 0;
const options_1 = require("./options");

@@ -133,3 +134,2 @@ const SEMICOLON = ';';

function splitQuery(sql, options = null) {
var _a;
const usedOptions = Object.assign(Object.assign({}, options_1.defaultSplitterOptions), options);

@@ -142,3 +142,3 @@ if (usedOptions.noSplit) {

end: sql.length,
currentDelimiter: ((_a = options) === null || _a === void 0 ? void 0 : _a.allowSemicolon) === false ? null : SEMICOLON,
currentDelimiter: (options === null || options === void 0 ? void 0 : options.allowSemicolon) === false ? null : SEMICOLON,
position: 0,

@@ -145,0 +145,0 @@ currentCommandStart: 0,

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

test('simple query', () => {
const output = splitQuery_1.splitQuery('select * from A');
const output = (0, splitQuery_1.splitQuery)('select * from A');
expect(output).toEqual(['select * from A']);
});
test('correct split 2 queries', () => {
const output = splitQuery_1.splitQuery('SELECT * FROM `table1`;SELECT * FROM `table2`;', options_1.mysqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)('SELECT * FROM `table1`;SELECT * FROM `table2`;', options_1.mysqlSplitterOptions);
expect(output).toEqual(['SELECT * FROM `table1`', 'SELECT * FROM `table2`']);
});
test('correct split 2 queries - no end semicolon', () => {
const output = splitQuery_1.splitQuery('SELECT * FROM `table1`;SELECT * FROM `table2`', options_1.mysqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)('SELECT * FROM `table1`;SELECT * FROM `table2`', options_1.mysqlSplitterOptions);
expect(output).toEqual(['SELECT * FROM `table1`', 'SELECT * FROM `table2`']);
});
test('delete empty query', () => {
const output = splitQuery_1.splitQuery(';;;\n;;SELECT * FROM `table1`;;;;;SELECT * FROM `table2`;;; ;;;', options_1.mysqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(';;;\n;;SELECT * FROM `table1`;;;;;SELECT * FROM `table2`;;; ;;;', options_1.mysqlSplitterOptions);
expect(output).toEqual(['SELECT * FROM `table1`', 'SELECT * FROM `table2`']);

@@ -24,3 +24,3 @@ });

const input = ['CREATE TABLE `a``b` (`c"d` INT)', 'CREATE TABLE `a````b` (`c"d` INT)'];
const output = splitQuery_1.splitQuery(input.join(';\n') + ';', options_1.mysqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(input.join(';\n') + ';', options_1.mysqlSplitterOptions);
expect(output).toEqual(input);

@@ -30,3 +30,3 @@ });

const input = ['CREATE TABLE a', "INSERT INTO a (x) VALUES ('1;2;3;4')"];
const output = splitQuery_1.splitQuery(input.join(';\n') + ';', options_1.mysqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(input.join(';\n') + ';', options_1.mysqlSplitterOptions);
expect(output).toEqual(input);

@@ -36,3 +36,3 @@ });

const input = ['CREATE TABLE [a;1]', "INSERT INTO [a;1] (x) VALUES ('1')"];
const output = splitQuery_1.splitQuery(input.join(';\n') + ';', Object.assign(Object.assign({}, options_1.mssqlSplitterOptions), { allowSemicolon: true }));
const output = (0, splitQuery_1.splitQuery)(input.join(';\n') + ';', Object.assign(Object.assign({}, options_1.mssqlSplitterOptions), { allowSemicolon: true }));
expect(output).toEqual(input);

@@ -42,3 +42,3 @@ });

const input = 'SELECT 1;\n DELIMITER $$\n SELECT 2; SELECT 3; \n DELIMITER ;';
const output = splitQuery_1.splitQuery(input, options_1.mysqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(input, options_1.mysqlSplitterOptions);
expect(output).toEqual(['SELECT 1', 'SELECT 2; SELECT 3;']);

@@ -48,3 +48,3 @@ });

const input = 'SELECT 1 -- comment1;comment2\n;SELECT 2';
const output = splitQuery_1.splitQuery(input, options_1.mysqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(input, options_1.mysqlSplitterOptions);
expect(output).toEqual(['SELECT 1 -- comment1;comment2', 'SELECT 2']);

@@ -54,3 +54,3 @@ });

const input = 'SELECT 1 /* comment1;comment2\ncomment3*/;SELECT 2';
const output = splitQuery_1.splitQuery(input, options_1.mysqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(input, options_1.mysqlSplitterOptions);
expect(output).toEqual(['SELECT 1 /* comment1;comment2\ncomment3*/', 'SELECT 2']);

@@ -60,3 +60,3 @@ });

const input = 'CREATE PROC $$ SELECT 1; SELECT 2; $$ ; SELECT 3';
const output = splitQuery_1.splitQuery(input, options_1.postgreSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(input, options_1.postgreSplitterOptions);
expect(output).toEqual(['CREATE PROC $$ SELECT 1; SELECT 2; $$', 'SELECT 3']);

@@ -66,3 +66,3 @@ });

const input = 'SELECT 1\ngo\nSELECT 2';
const output = splitQuery_1.splitQuery(input, options_1.mssqlSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(input, options_1.mssqlSplitterOptions);
expect(output).toEqual(['SELECT 1', 'SELECT 2']);

@@ -72,4 +72,4 @@ });

const input = 'SELECT 1;SELECT 2';
const output = splitQuery_1.splitQuery(input, options_1.noSplitSplitterOptions);
const output = (0, splitQuery_1.splitQuery)(input, options_1.noSplitSplitterOptions);
expect(output).toEqual(['SELECT 1;SELECT 2']);
});
{
"version": "4.3.0",
"version": "4.3.1",
"name": "dbgate-query-splitter",

@@ -30,3 +30,3 @@ "main": "lib/index.js",

"devDependencies": {
"dbgate-types": "^4.3.0",
"dbgate-types": "^4.3.1",
"@types/jest": "^25.1.4",

@@ -36,4 +36,4 @@ "@types/node": "^13.7.0",

"ts-jest": "^25.2.1",
"typescript": "^3.7.5"
"typescript": "^4.4.3"
}
}
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