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

dbgate-query-splitter

Package Overview
Dependencies
Maintainers
1
Versions
63
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.7.4 to 4.8.0

2

lib/options.d.ts

@@ -18,2 +18,3 @@ export interface SplitterOptions {

returnRichInfo: boolean;
splitByLines: boolean;
}

@@ -27,1 +28,2 @@ export declare const defaultSplitterOptions: SplitterOptions;

export declare const noSplitSplitterOptions: SplitterOptions;
export declare const redisSplitterOptions: SplitterOptions;

4

lib/options.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.noSplitSplitterOptions = exports.mongoSplitterOptions = exports.sqliteSplitterOptions = exports.postgreSplitterOptions = exports.mssqlSplitterOptions = exports.mysqlSplitterOptions = exports.defaultSplitterOptions = void 0;
exports.redisSplitterOptions = exports.noSplitSplitterOptions = exports.mongoSplitterOptions = exports.sqliteSplitterOptions = exports.postgreSplitterOptions = exports.mssqlSplitterOptions = exports.mysqlSplitterOptions = exports.defaultSplitterOptions = void 0;
exports.defaultSplitterOptions = {

@@ -17,2 +17,3 @@ stringsBegins: ["'"],

returnRichInfo: false,
splitByLines: false,
};

@@ -25,1 +26,2 @@ exports.mysqlSplitterOptions = Object.assign(Object.assign({}, exports.defaultSplitterOptions), { allowCustomDelimiter: true, stringsBegins: ["'", '`'], stringsEnds: { "'": "'", '`': '`' }, stringEscapes: { "'": '\\', '`': '`' } });

exports.noSplitSplitterOptions = Object.assign(Object.assign({}, exports.defaultSplitterOptions), { noSplit: true });
exports.redisSplitterOptions = Object.assign(Object.assign({}, exports.defaultSplitterOptions), { splitByLines: true });

@@ -198,3 +198,24 @@ "use strict";

}
function splitByLines(context) {
while (context.position < context.end) {
if (context.source[context.position] == '\n') {
pushQuery(context);
context.commandPart = '';
movePosition(context, 1);
context.currentCommandStart = context.position;
markStartCommand(context);
}
else {
movePosition(context, 1);
}
}
if (context.end > context.currentCommandStart) {
context.commandPart += context.source.slice(context.currentCommandStart, context.position);
}
}
function splitQueryLine(context) {
if (context.options.splitByLines) {
splitByLines(context);
return;
}
while (context.position < context.end) {

@@ -201,0 +222,0 @@ const token = scanToken(context);

@@ -71,2 +71,10 @@ "use strict";

});
test('redis split by newline', () => {
const output = (0, splitQuery_1.splitQuery)('SET x 1\nSET y 2', options_1.redisSplitterOptions);
expect(output).toEqual(['SET x 1', 'SET y 2']);
});
test('redis split by newline 2', () => {
const output = (0, splitQuery_1.splitQuery)('SET x 1\n\nSET y 2\n', options_1.redisSplitterOptions);
expect(output).toEqual(['SET x 1', 'SET y 2']);
});
test('count lines', () => {

@@ -73,0 +81,0 @@ const output = (0, splitQuery_1.splitQuery)('SELECT * FROM `table1`;\nSELECT * FROM `table2`;', Object.assign(Object.assign({}, options_1.mysqlSplitterOptions), { returnRichInfo: true }));

{
"version": "4.7.4",
"version": "4.8.0",
"name": "dbgate-query-splitter",

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

"devDependencies": {
"dbgate-types": "^4.7.4",
"dbgate-types": "^4.8.0",
"@types/jest": "^25.1.4",

@@ -33,0 +33,0 @@ "@types/node": "^13.7.0",

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