dbgate-query-splitter
Advanced tools
Comparing version 4.10.5 to 4.11.0
export { splitQuery } from './splitQuery'; | ||
export { splitQueryStream } from './splitQueryStream'; | ||
export * from './options'; |
@@ -17,5 +17,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.splitQuery = void 0; | ||
exports.splitQueryStream = exports.splitQuery = void 0; | ||
var splitQuery_1 = require("./splitQuery"); | ||
Object.defineProperty(exports, "splitQuery", { enumerable: true, get: function () { return splitQuery_1.splitQuery; } }); | ||
var splitQueryStream_1 = require("./splitQueryStream"); | ||
Object.defineProperty(exports, "splitQueryStream", { enumerable: true, get: function () { return splitQueryStream_1.splitQueryStream; } }); | ||
__exportStar(require("./options"), exports); |
@@ -0,1 +1,2 @@ | ||
export declare type QueryParameterStyle = null | '?' | '$' | '@' | ':' | '#'; | ||
export interface SplitterOptions { | ||
@@ -25,2 +26,3 @@ stringsBegins: string[]; | ||
copyFromStdin: boolean; | ||
queryParameterStyle: QueryParameterStyle; | ||
} | ||
@@ -27,0 +29,0 @@ export declare const defaultSplitterOptions: SplitterOptions; |
@@ -24,2 +24,3 @@ "use strict"; | ||
copyFromStdin: false, | ||
queryParameterStyle: null, | ||
}; | ||
@@ -26,0 +27,0 @@ exports.mysqlSplitterOptions = Object.assign(Object.assign({}, exports.defaultSplitterOptions), { allowCustomDelimiter: true, stringsBegins: ["'", '`'], stringsEnds: { "'": "'", '`': '`' }, stringEscapes: { "'": '\\', '`': '`' } }); |
@@ -24,2 +24,12 @@ import { SplitterOptions } from './options'; | ||
} | ||
export interface ScannerContext { | ||
readonly options: SplitterOptions; | ||
readonly source: string; | ||
readonly position: number; | ||
readonly currentDelimiter: string; | ||
readonly end: number; | ||
readonly wasDataOnLine: boolean; | ||
readonly isCopyFromStdin: boolean; | ||
readonly isCopyFromStdinCandidate: boolean; | ||
} | ||
export interface SplitLineContext extends SplitStreamContext { | ||
@@ -46,2 +56,9 @@ source: string; | ||
export declare type SplitResultItem = string | SplitResultItemRich; | ||
interface Token { | ||
type: 'string' | 'delimiter' | 'whitespace' | 'eoln' | 'data' | 'slash_delimiter' | 'set_delimiter' | 'set_sqlterminator' | 'comment' | 'go_delimiter' | 'create_routine' | 'copy' | 'copy_stdin_start' | 'copy_stdin_end' | 'copy_stdin_line' | 'parameter'; | ||
length: number; | ||
lengthWithoutWhitespace?: number; | ||
value?: string; | ||
} | ||
export declare function scanToken(context: ScannerContext): Token; | ||
export declare function splitQueryLine(context: SplitLineContext): void; | ||
@@ -48,0 +65,0 @@ export declare function getInitialDelimiter(options: SplitterOptions): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.splitQuery = exports.finishSplitStream = exports.getInitialDelimiter = exports.splitQueryLine = void 0; | ||
exports.splitQuery = exports.finishSplitStream = exports.getInitialDelimiter = exports.splitQueryLine = exports.scanToken = void 0; | ||
const options_1 = require("./options"); | ||
@@ -74,2 +74,3 @@ const SEMICOLON = ';'; | ||
function scanToken(context) { | ||
var _a; | ||
let pos = context.position; | ||
@@ -115,2 +116,17 @@ const s = context.source; | ||
} | ||
if (context.options.queryParameterStyle && | ||
((_a = context.options.queryParameterStyle) === null || _a === void 0 ? void 0 : _a.length) == 1 && | ||
ch == context.options.queryParameterStyle && | ||
(context.options.queryParameterStyle == '?' || /[a-zA-Z0-9_]/.test(s[pos + 1]))) { | ||
pos++; | ||
if (context.options.queryParameterStyle != '?') { | ||
while (pos < context.end && /[a-zA-Z0-9_]/.test(s[pos])) | ||
pos++; | ||
} | ||
return { | ||
type: 'parameter', | ||
value: s.slice(context.position, pos), | ||
length: pos - context.position, | ||
}; | ||
} | ||
if (context.currentDelimiter && s.slice(pos).startsWith(context.currentDelimiter)) { | ||
@@ -235,2 +251,3 @@ return { | ||
} | ||
exports.scanToken = scanToken; | ||
function containsDataAfterDelimiterOnLine(context, delimiter) { | ||
@@ -364,2 +381,6 @@ var _a; | ||
break; | ||
case 'parameter': | ||
movePosition(context, token.length, false); | ||
context.wasDataOnLine = true; | ||
break; | ||
case 'whitespace': | ||
@@ -366,0 +387,0 @@ movePosition(context, token.length, true); |
{ | ||
"version": "4.10.5", | ||
"version": "4.11.0", | ||
"name": "dbgate-query-splitter", | ||
@@ -4,0 +4,0 @@ "main": "lib/index.js", |
55022
19
1180