sql-formatter
Advanced tools
Comparing version 10.3.0 to 10.4.0
@@ -91,2 +91,5 @@ "use strict"; | ||
case _ast.NodeType.property_access: | ||
return this.formatPropertyAccess(node); | ||
case _ast.NodeType.parenthesis: | ||
@@ -150,2 +153,11 @@ return this.formatParenthesis(node); | ||
}, { | ||
key: "formatPropertyAccess", | ||
value: function formatPropertyAccess(_ref3) { | ||
var object = _ref3.object, | ||
property = _ref3.property; | ||
this.formatNode(object); | ||
this.layout.add(_Layout.WS.NO_SPACE, '.'); | ||
this.formatNode(property); | ||
} | ||
}, { | ||
key: "formatParenthesis", | ||
@@ -253,4 +265,4 @@ value: function formatParenthesis(node) { | ||
key: "formatOperator", | ||
value: function formatOperator(_ref3) { | ||
var text = _ref3.text; | ||
value: function formatOperator(_ref4) { | ||
var text = _ref4.text; | ||
@@ -261,3 +273,3 @@ // special operator | ||
return; | ||
} else if (text === '.' || text === '::') { | ||
} else if (text === '::') { | ||
this.layout.add(_Layout.WS.NO_SPACE, text); | ||
@@ -264,0 +276,0 @@ return; |
@@ -75,2 +75,7 @@ "use strict"; | ||
case _ast.NodeType.property_access: | ||
// +1 for the separating dot | ||
length += this.inlineWidth([node.object]) + 1 + this.inlineWidth([node.property]); | ||
break; | ||
case _ast.NodeType.parenthesis: | ||
@@ -77,0 +82,0 @@ length += this.inlineParenthesisWidth(node); |
@@ -28,2 +28,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -49,4 +51,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]']); | ||
@@ -113,8 +113,10 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax | ||
prefixes: ['R', 'B', 'RB', 'BR'] | ||
}, '""-bs', "''-bs", { | ||
quote: '""-raw', | ||
prefixes: ['R', 'B', 'RB', 'BR'], | ||
requirePrefix: true | ||
}, { | ||
quote: '""', | ||
prefixes: ['R', 'B', 'RB', 'BR'] | ||
}, { | ||
quote: "''", | ||
prefixes: ['R', 'B', 'RB', 'BR'] | ||
quote: "''-raw", | ||
prefixes: ['R', 'B', 'RB', 'BR'], | ||
requirePrefix: true | ||
}], | ||
@@ -131,3 +133,3 @@ identTypes: ['``'], | ||
lineCommentTypes: ['--', '#'], | ||
operators: BigQueryFormatter.operators, | ||
operators: ['&', '|', '^', '~', '>>', '<<', '||'], | ||
postProcess: postProcess | ||
@@ -143,4 +145,2 @@ }); | ||
_defineProperty(BigQueryFormatter, "operators", ['~', '>>', '<<', '||']); | ||
function postProcess(tokens) { | ||
@@ -147,0 +147,0 @@ return detectArraySubscripts(combineParameterizedTypes(tokens)); |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
@@ -89,6 +87,10 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
stringTypes: [{ | ||
quote: "''", | ||
prefixes: ['G', 'N', 'X', 'BX', 'GX', 'UX', 'U&'] | ||
quote: "''-qq", | ||
prefixes: ['G', 'N', 'U&'] | ||
}, { | ||
quote: "''-raw", | ||
prefixes: ['X', 'BX', 'GX', 'UX'], | ||
requirePrefix: true | ||
}], | ||
identTypes: ["\"\""], | ||
identTypes: ["\"\"-qq"], | ||
paramTypes: { | ||
@@ -102,3 +104,3 @@ positional: true, | ||
}, | ||
operators: Db2Formatter.operators | ||
operators: ['**', '¬=', '¬>', '¬<', '!>', '!<', '||'] | ||
}); | ||
@@ -112,6 +114,3 @@ } | ||
exports["default"] = Db2Formatter; | ||
_defineProperty(Db2Formatter, "operators", ['**', '¬=', '¬>', '¬<', '!>', '!<', '||']); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=db2.formatter.js.map |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
@@ -94,3 +92,3 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
extraParens: ['[]'], | ||
stringTypes: ['""', "''"], | ||
stringTypes: ['""-bs', "''-bs"], | ||
identTypes: ['``'], | ||
@@ -102,3 +100,3 @@ variableTypes: [{ | ||
}], | ||
operators: HiveFormatter.operators | ||
operators: ['%', '~', '^', '|', '&', '<=>', '==', '!', '||'] | ||
}); | ||
@@ -112,6 +110,3 @@ } | ||
exports["default"] = HiveFormatter; | ||
_defineProperty(HiveFormatter, "operators", ['<=>', '==', '||']); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=hive.formatter.js.map |
@@ -28,2 +28,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -49,4 +51,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT | DISTINCTROW]']); | ||
@@ -95,6 +95,7 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc. | ||
stringTypes: [{ | ||
quote: "''", | ||
prefixes: ['B', 'X'] | ||
}, '""'], | ||
stringTypes: ['""-qq-bs', "''-qq-bs", { | ||
quote: "''-raw", | ||
prefixes: ['B', 'X'], | ||
requirePrefix: true | ||
}], | ||
identTypes: ['``'], | ||
@@ -109,7 +110,7 @@ identChars: { | ||
}, { | ||
quote: '""', | ||
quote: '""-qq-bs', | ||
prefixes: ['@'], | ||
requirePrefix: true | ||
}, { | ||
quote: "''", | ||
quote: "''-qq-bs", | ||
prefixes: ['@'], | ||
@@ -126,3 +127,3 @@ requirePrefix: true | ||
lineCommentTypes: ['--', '#'], | ||
operators: MariaDbFormatter.operators, | ||
operators: ['%', ':=', '&', '|', '^', '~', '<<', '>>', '<=>', '&&', '||', '!'], | ||
postProcess: postProcess | ||
@@ -138,4 +139,2 @@ }); | ||
_defineProperty(MariaDbFormatter, "operators", [':=', '<<', '>>', '<=>', '&&', '||']); | ||
function postProcess(tokens) { | ||
@@ -142,0 +141,0 @@ return tokens.map(function (token, i) { |
@@ -28,2 +28,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -49,4 +51,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT | DISTINCTROW]']); | ||
@@ -96,6 +96,10 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc. | ||
stringTypes: [{ | ||
quote: "''", | ||
prefixes: ['B', 'N', 'X'] | ||
}, '""'], | ||
stringTypes: ['""-qq-bs', { | ||
quote: "''-qq-bs", | ||
prefixes: ['N'] | ||
}, { | ||
quote: "''-raw", | ||
prefixes: ['B', 'X'], | ||
requirePrefix: true | ||
}], | ||
identTypes: ['``'], | ||
@@ -110,7 +114,7 @@ identChars: { | ||
}, { | ||
quote: '""', | ||
quote: '""-qq-bs', | ||
prefixes: ['@'], | ||
requirePrefix: true | ||
}, { | ||
quote: "''", | ||
quote: "''-qq-bs", | ||
prefixes: ['@'], | ||
@@ -127,3 +131,3 @@ requirePrefix: true | ||
lineCommentTypes: ['--', '#'], | ||
operators: MySqlFormatter.operators, | ||
operators: ['%', ':=', '&', '|', '^', '~', '<<', '>>', '<=>', '->', '->>', '&&', '||', '!'], | ||
postProcess: postProcess | ||
@@ -139,4 +143,2 @@ }); | ||
_defineProperty(MySqlFormatter, "operators", ['~', ':=', '<<', '>>', '<=>', '&&', '||', '->', '->>']); | ||
function postProcess(tokens) { | ||
@@ -143,0 +145,0 @@ return tokens.map(function (token, i) { |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
@@ -86,3 +84,3 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
// which simplifies writing tests that are shared between all dialects. | ||
stringTypes: ['""', "''"], | ||
stringTypes: ['""-bs', "''-bs"], | ||
identTypes: ['``'], | ||
@@ -96,3 +94,3 @@ extraParens: ['[]', '{}'], | ||
lineCommentTypes: ['#', '--'], | ||
operators: N1qlFormatter.operators | ||
operators: ['%', '==', ':', '||'] | ||
}); | ||
@@ -106,6 +104,3 @@ } | ||
exports["default"] = N1qlFormatter; | ||
_defineProperty(N1qlFormatter, "operators", ['==', '||']); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=n1ql.formatter.js.map |
@@ -28,2 +28,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -49,4 +51,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT | UNIQUE]']); | ||
@@ -94,3 +94,3 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
stringTypes: [{ | ||
quote: "''", | ||
quote: "''-qq", | ||
prefixes: ['N'] | ||
@@ -101,3 +101,6 @@ }, { | ||
}], | ||
identTypes: ["\"\""], | ||
// PL/SQL doesn't actually support escaping of quotes in identifiers, | ||
// but for the sake of simpler testing we'll support this anyway | ||
// as all other SQL dialects with "identifiers" do. | ||
identTypes: ["\"\"-qq"], | ||
identChars: { | ||
@@ -115,3 +118,4 @@ rest: '$#' | ||
// Empty object used on purpose to not allow $ and # chars as specified in identChars | ||
operators: PlSqlFormatter.operators, | ||
operators: ['**', ':=', '%', '~=', '^=', // '..', // Conflicts with float followed by dot (so "2..3" gets parsed as ["2.", ".", "3"]) | ||
'>>', '<<', '=>', '@', '||'], | ||
postProcess: postProcess | ||
@@ -127,5 +131,2 @@ }); | ||
_defineProperty(PlSqlFormatter, "operators", ['||', '**', ':=', '~=', '^=', '>>', '<<', '=>' // '..' // breaks operator test, handled by . | ||
]); | ||
function postProcess(tokens) { | ||
@@ -132,0 +133,0 @@ var previousReservedToken = _token.EOF_TOKEN; |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
@@ -63,15 +61,3 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
var reservedPhrases = (0, _expandPhrases.expandPhrases)(['ON DELETE', 'ON UPDATE', '{ROWS | RANGE | GROUPS} BETWEEN', // https://www.postgresql.org/docs/current/datatype-datetime.html | ||
'{TIMESTAMP | TIME} {WITH | WITHOUT} TIME ZONE']); | ||
var binaryOperators = [// Math Operators | ||
'<<', '>>', '|/', '||/', '!!', // String Operators | ||
'||', // Pattern Matching Operators | ||
'~~', '~~*', '!~~', '!~~*', // POSIX RegExp operators | ||
'~', '~*', '!~', '!~*', // Similarity Operators | ||
'<%', '<<%', '%>', '%>>', // Byte Comparison Operators | ||
'~>~', '~<~', '~>=~', '~<=~', // Geometric operators | ||
'@-@', '@@', '#', '##', '<->', '&&', '&<', '&>', '<<|', '&<|', '|>>', '|&>', '<^', '^>', '?#', '?-', '?|', '?-|', '?||', '@>', '<@', '~=', // Network Address operators | ||
'>>=', '<<=', // Text Search Operators | ||
'@@@', // JSON Operators | ||
'?', '@?', '?&', '->', '->>', '#>', '#>>', '#-', // Other Operators | ||
':=', '::', '=>', '-|-']; // https://www.postgresql.org/docs/14/index.html | ||
'{TIMESTAMP | TIME} {WITH | WITHOUT} TIME ZONE']); // https://www.postgresql.org/docs/14/index.html | ||
@@ -104,7 +90,15 @@ var PostgreSqlFormatter = /*#__PURE__*/function (_Formatter) { | ||
stringTypes: ['$$', { | ||
quote: "''", | ||
prefixes: ['B', 'E', 'X', 'U&'] | ||
quote: "''-qq", | ||
prefixes: ['U&'] | ||
}, { | ||
quote: "''-bs", | ||
prefixes: ['E'], | ||
requirePrefix: true | ||
}, { | ||
quote: "''-raw", | ||
prefixes: ['B', 'X'], | ||
requirePrefix: true | ||
}], | ||
identTypes: [{ | ||
quote: '""', | ||
quote: '""-qq', | ||
prefixes: ['U&'] | ||
@@ -118,3 +112,18 @@ }], | ||
}, | ||
operators: PostgreSqlFormatter.operators | ||
operators: [// Arithmetic | ||
'%', '^', '|/', '||/', '@', // Assignment | ||
':=', // Bitwise | ||
'&', '|', '#', '~', '<<', '>>', // Byte comparison | ||
'~>~', '~<~', '~>=~', '~<=~', // Geometric | ||
'@-@', '@@', '##', '<->', '&&', '&<', '&>', '<<|', '&<|', '|>>', '|&>', '<^', '^>', '?#', '?-', '?|', '?-|', '?||', '@>', '<@', '~=', // JSON | ||
'?', '@?', '?&', '->', '->>', '#>', '#>>', '#-', // Named function params | ||
'=>', // Network address | ||
'>>=', '<<=', // Pattern matching | ||
'~~', '~~*', '!~~', '!~~*', // POSIX RegExp | ||
'~', '~*', '!~', '!~*', // Range/multirange | ||
'-|-', // String concatenation | ||
'||', // Text search | ||
'@@@', '!!', // Trigram/trigraph | ||
'<%', '%>', '<<%', '%>>', '<<->', '<->>', '<<<->', '<->>>', // Type cast | ||
'::'] | ||
}); | ||
@@ -128,6 +137,3 @@ } | ||
exports["default"] = PostgreSqlFormatter; | ||
_defineProperty(PostgreSqlFormatter, "operators", binaryOperators); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=postgresql.formatter.js.map |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
@@ -89,4 +87,4 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
reservedFunctionNames: _redshift.functions, | ||
stringTypes: ["''"], | ||
identTypes: ["\"\""], | ||
stringTypes: ["''-qq"], | ||
identTypes: ["\"\"-qq"], | ||
identChars: { | ||
@@ -98,3 +96,4 @@ first: '#' | ||
}, | ||
operators: RedshiftFormatter.operators | ||
operators: ['^', '%', '@', '|/', '||/', '&', '|', // '#', conflicts with first char of identifier | ||
'~', '<<', '>>', '||'] | ||
}); | ||
@@ -108,6 +107,3 @@ } | ||
exports["default"] = RedshiftFormatter; | ||
_defineProperty(RedshiftFormatter, "operators", ['~', '|/', '||/', '<<', '>>', '||']); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=redshift.formatter.js.map |
@@ -28,2 +28,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -49,4 +51,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT | DISTINCTROW]']); | ||
@@ -93,6 +93,7 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
// TODO: support _binary"some string" prefix | ||
stringTypes: [{ | ||
quote: "''", | ||
prefixes: ['B', 'X'] | ||
}, '""'], | ||
stringTypes: ['""-qq-bs', "''-qq-bs", { | ||
quote: "''-raw", | ||
prefixes: ['B', 'X'], | ||
requirePrefix: true | ||
}], | ||
identTypes: ['``'], | ||
@@ -112,3 +113,3 @@ identChars: { | ||
lineCommentTypes: ['--', '#'], | ||
operators: SingleStoreDbFormatter.operators, | ||
operators: [':=', '&', '|', '^', '~', '<<', '>>', '<=>', '&&', '||'], | ||
postProcess: postProcess | ||
@@ -124,4 +125,2 @@ }); | ||
_defineProperty(SingleStoreDbFormatter, "operators", ['~', ':=', '<=>', '<<', '>>', '&&', '||']); | ||
function postProcess(tokens) { | ||
@@ -128,0 +127,0 @@ return tokens.map(function (token, i) { |
@@ -28,2 +28,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -49,4 +51,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
// http://spark.apache.org/docs/latest/sql-ref-syntax.html | ||
@@ -98,8 +98,10 @@ var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
extraParens: ['[]'], | ||
stringTypes: [{ | ||
quote: "''", | ||
prefixes: ['R', 'X'] | ||
stringTypes: ["''-bs", '""-bs', { | ||
quote: "''-raw", | ||
prefixes: ['R', 'X'], | ||
requirePrefix: true | ||
}, { | ||
quote: '""', | ||
prefixes: ['R', 'X'] | ||
quote: '""-raw', | ||
prefixes: ['R', 'X'], | ||
requirePrefix: true | ||
}], | ||
@@ -112,3 +114,3 @@ identTypes: ['``'], | ||
}], | ||
operators: SparkFormatter.operators, | ||
operators: ['%', '~', '^', '|', '&', '<=>', '==', '!', '||', '->'], | ||
postProcess: postProcess | ||
@@ -124,4 +126,2 @@ }); | ||
_defineProperty(SparkFormatter, "operators", ['~', '<=>', '&&', '||', '==', '->']); | ||
function postProcess(tokens) { | ||
@@ -128,0 +128,0 @@ return tokens.map(function (token, i) { |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
@@ -88,6 +86,10 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
stringTypes: [{ | ||
quote: "''", | ||
prefixes: ['N', 'X', 'U&'] | ||
quote: "''-qq-bs", | ||
prefixes: ['N', 'U&'] | ||
}, { | ||
quote: "''-raw", | ||
prefixes: ['X'], | ||
requirePrefix: true | ||
}], | ||
identTypes: ["\"\"", '``'], | ||
identTypes: ["\"\"-qq", '``'], | ||
paramTypes: { | ||
@@ -104,6 +106,3 @@ positional: true | ||
exports["default"] = SqlFormatter; | ||
_defineProperty(SqlFormatter, "operators", []); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=sql.formatter.js.map |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
@@ -73,4 +71,3 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
key: "tokenizer", | ||
value: // https://www.sqlite.org/lang_expr.html | ||
function tokenizer() { | ||
value: function tokenizer() { | ||
return new _Tokenizer["default"]({ | ||
@@ -85,8 +82,10 @@ reservedCommands: reservedCommands, | ||
reservedFunctionNames: _sqlite.functions, | ||
stringTypes: [{ | ||
quote: "''", | ||
prefixes: ['X'] | ||
} // { quote: '""', prefixes: ['X'] }, // currently conflict with "" identifiers | ||
stringTypes: ["''-qq", { | ||
quote: "''-raw", | ||
prefixes: ['X'], | ||
requirePrefix: true | ||
} // Depending on context SQLite also supports double-quotes for strings, | ||
// and single-quotes for identifiers. | ||
], | ||
identTypes: ["\"\"", '``', '[]'], | ||
identTypes: ["\"\"-qq", '``', '[]'], | ||
// https://www.sqlite.org/lang_expr.html#parameters | ||
@@ -98,3 +97,3 @@ paramTypes: { | ||
}, | ||
operators: SqliteFormatter.operators | ||
operators: ['%', '~', '&', '|', '<<', '>>', '==', '->', '->>', '||'] | ||
}); | ||
@@ -108,6 +107,3 @@ } | ||
exports["default"] = SqliteFormatter; | ||
_defineProperty(SqliteFormatter, "operators", ['~', '->', '->>', '||', '<<', '>>', '==']); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=sqlite.formatter.js.map |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); // https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L41 | ||
@@ -78,5 +76,3 @@ | ||
key: "tokenizer", | ||
value: // https://trino.io/docs/current/functions/list.html#id1 | ||
// https://trino.io/docs/current/sql/match-recognize.html#row-pattern-syntax | ||
function tokenizer() { | ||
value: function tokenizer() { | ||
return new _Tokenizer["default"]({ | ||
@@ -99,11 +95,17 @@ reservedCommands: reservedCommands, | ||
stringTypes: [{ | ||
quote: "''", | ||
prefixes: ['X', 'U&'] | ||
quote: "''-qq", | ||
prefixes: ['U&'] | ||
}, { | ||
quote: "''-raw", | ||
prefixes: ['X'], | ||
requirePrefix: true | ||
}], | ||
// https://trino.io/docs/current/language/reserved.html | ||
identTypes: ['""'], | ||
identTypes: ['""-qq'], | ||
paramTypes: { | ||
positional: true | ||
}, | ||
operators: TrinoFormatter.operators | ||
operators: ['%', '->', ':', '||', // Row pattern syntax | ||
'|', '^', '$' // '?', conflicts with positional placeholders | ||
] | ||
}); | ||
@@ -117,6 +119,3 @@ } | ||
exports["default"] = TrinoFormatter; | ||
_defineProperty(TrinoFormatter, "operators", ['||', '->']); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=trino.formatter.js.map |
@@ -42,4 +42,2 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var reservedSelect = (0, _expandPhrases.expandPhrases)(['SELECT [ALL | DISTINCT]']); | ||
@@ -87,6 +85,6 @@ var reservedCommands = (0, _expandPhrases.expandPhrases)([// queries | ||
stringTypes: [{ | ||
quote: "''", | ||
quote: "''-qq", | ||
prefixes: ['N'] | ||
}], | ||
identTypes: ["\"\"", '[]'], | ||
identTypes: ["\"\"-qq", '[]'], | ||
identChars: { | ||
@@ -100,3 +98,3 @@ first: '#@', | ||
}, | ||
operators: TSqlFormatter.operators // TODO: Support for money constants | ||
operators: ['%', '&', '|', '^', '~', '!<', '!>', '+=', '-=', '*=', '/=', '%=', '|=', '&=', '^=', '::'] // TODO: Support for money constants | ||
@@ -111,6 +109,3 @@ }); | ||
exports["default"] = TSqlFormatter; | ||
_defineProperty(TSqlFormatter, "operators", ['~', '!<', '!>', '+=', '-=', '*=', '/=', '%=', '|=', '&=', '^=', '::']); | ||
module.exports = exports.default; | ||
//# sourceMappingURL=tsql.formatter.js.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8; | ||
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14; | ||
@@ -61,4 +61,2 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
* Builds a RegExp containing all operators for a SQL dialect | ||
* @param {string} monadOperators - concatenated string of all 1-length operators | ||
* @param {string[]} polyadOperators - list of strings of all >1-length operators | ||
*/ | ||
@@ -69,4 +67,4 @@ | ||
var operator = function operator(monadOperators, polyadOperators) { | ||
return (0, _regexUtil.patternToRegex)("".concat((0, _utils.sortByLengthDesc)(polyadOperators).map(_regexUtil.escapeRegExp).join('|'), "|") + "[".concat(monadOperators.split('').map(_regexUtil.escapeRegExp).join(''), "]")); | ||
var operator = function operator(operators) { | ||
return (0, _regexUtil.patternToRegex)("".concat((0, _utils.sortByLengthDesc)(operators).map(_regexUtil.escapeRegExp).join('|'))); | ||
}; // Negative lookahead to avoid matching a keyword that's actually part of identifier, | ||
@@ -146,23 +144,41 @@ // which can happen when identifier allows word-boundary characters inside it. | ||
return qStringPattern; | ||
}; // This enables the following quote styles: | ||
// 1. backtick quoted using `` to escape | ||
// 2. square bracket quoted (SQL Server) using ]] to escape | ||
// 3. double quoted using "" or \" to escape | ||
// 4. single quoted using '' or \' to escape | ||
// 5. PostgreSQL dollar-quoted | ||
// 6. BigQuery '''triple-quoted''' | ||
// 7. BigQuery """triple-quoted""" | ||
// 8. Hive and Spark variables: ${name} | ||
// 9. Oracle q'' strings: q'<text>' q'|text|' ... | ||
}; // Regex patterns for all supported quote styles. | ||
// | ||
// Most of them have a single escaping-style built in, | ||
// but "" and '' support multiple versions of escapes, | ||
// which must be selected with suffixes: -qq, -bs, -qq-bs, -raw | ||
var quotePatterns = { | ||
'``': '(?:`[^`]*(?:$|`))+', | ||
'[]': String.raw(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["(?:[[^]]*(?:$|]))(?:][^]]*(?:$|]))*"], ["(?:\\[[^\\]]*(?:$|\\]))(?:\\][^\\]]*(?:$|\\]))*"]))), | ||
'""': String.raw(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["(?:\"[^\"\\]*(?:\\.[^\"\\]*)*(?:\"|$))+"], ["(?:\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*(?:\"|$))+"]))), | ||
"''": String.raw(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["(?:'[^'\\]*(?:\\.[^'\\]*)*(?:'|$))+"], ["(?:'[^'\\\\]*(?:\\\\.[^'\\\\]*)*(?:'|$))+"]))), | ||
'$$': String.raw(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["(?<tag>$w*$)[sS]*?(?:k<tag>|$)"], ["(?<tag>\\$\\w*\\$)[\\s\\S]*?(?:\\k<tag>|$)"]))), | ||
"'''..'''": String.raw(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["'''[^\\]*?(?:\\.[^\\]*?)*?(?:'''|$)"], ["'''[^\\\\]*?(?:\\\\.[^\\\\]*?)*?(?:'''|$)"]))), | ||
'""".."""': String.raw(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\"\"\"[^\\]*?(?:\\.[^\\]*?)*?(?:\"\"\"|$)"], ["\"\"\"[^\\\\]*?(?:\\\\.[^\\\\]*?)*?(?:\"\"\"|$)"]))), | ||
'{}': String.raw(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["(?:{[^}]*(?:$|}))"], ["(?:\\{[^\\}]*(?:$|\\}))"]))), | ||
// - backtick quoted (using `` to escape) | ||
'``': '(?:`[^`]*`)+', | ||
// - Transact-SQL square bracket quoted (using ]] to escape) | ||
'[]': String.raw(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["(?:[[^]]*])(?:][^]]*])*"], ["(?:\\[[^\\]]*\\])(?:\\][^\\]]*\\])*"]))), | ||
// double-quoted | ||
'""-qq': String.raw(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["(?:\"[^\"]*\")+"]))), | ||
// with repeated quote escapes | ||
'""-bs': String.raw(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["(?:\"[^\"\\]*(?:\\.[^\"\\]*)*\")"], ["(?:\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")"]))), | ||
// with backslash escapes | ||
'""-qq-bs': String.raw(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["(?:\"[^\"\\]*(?:\\.[^\"\\]*)*\")+"], ["(?:\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")+"]))), | ||
// with repeated quote or backslash escapes | ||
'""-raw': String.raw(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["(?:\"[^\"]*\")"]))), | ||
// no escaping | ||
// single-quoted | ||
"''-qq": String.raw(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["(?:'[^']*')+"]))), | ||
// with repeated quote escapes | ||
"''-bs": String.raw(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["(?:'[^'\\]*(?:\\.[^'\\]*)*')"], ["(?:'[^'\\\\]*(?:\\\\.[^'\\\\]*)*')"]))), | ||
// with backslash escapes | ||
"''-qq-bs": String.raw(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["(?:'[^'\\]*(?:\\.[^'\\]*)*')+"], ["(?:'[^'\\\\]*(?:\\\\.[^'\\\\]*)*')+"]))), | ||
// with repeated quote or backslash escapes | ||
"''-raw": String.raw(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["(?:'[^']*')"]))), | ||
// no escaping | ||
// PostgreSQL dollar-quoted | ||
'$$': String.raw(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["(?<tag>$w*$)[sS]*?k<tag>"], ["(?<tag>\\$\\w*\\$)[\\s\\S]*?\\k<tag>"]))), | ||
// BigQuery '''triple-quoted''' (using \' to escape) | ||
"'''..'''": String.raw(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["'''[^\\]*?(?:\\.[^\\]*?)*?'''"], ["'''[^\\\\]*?(?:\\\\.[^\\\\]*?)*?'''"]))), | ||
// BigQuery """triple-quoted""" (using \" to escape) | ||
'""".."""': String.raw(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\"\"\"[^\\]*?(?:\\.[^\\]*?)*?\"\"\""], ["\"\"\"[^\\\\]*?(?:\\\\.[^\\\\]*?)*?\"\"\""]))), | ||
// Hive and Spark variables: ${name} | ||
'{}': String.raw(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["(?:{[^}]*})"], ["(?:\\{[^\\}]*\\})"]))), | ||
// Oracle q'' strings: q'<text>' q'|text|' ... | ||
"q''": buildQStringPatterns() | ||
@@ -169,0 +185,0 @@ }; |
@@ -39,2 +39,3 @@ "use strict"; | ||
TokenType["ASTERISK"] = "ASTERISK"; | ||
TokenType["DOT"] = "DOT"; | ||
TokenType["OPEN_PAREN"] = "OPEN_PAREN"; | ||
@@ -41,0 +42,0 @@ TokenType["CLOSE_PAREN"] = "CLOSE_PAREN"; |
@@ -182,6 +182,10 @@ "use strict"; | ||
type: _token.TokenType.OPERATOR, | ||
regex: regex.operator('+-/%&|^><=.:$@#?~!', ['<>', '<=', '>=', '!='].concat(_toConsumableArray((_cfg$operators = cfg.operators) !== null && _cfg$operators !== void 0 ? _cfg$operators : []))) | ||
regex: regex.operator([// standard operators | ||
'+', '-', '/', '>', '<', '=', '<>', '<=', '>=', '!='].concat(_toConsumableArray((_cfg$operators = cfg.operators) !== null && _cfg$operators !== void 0 ? _cfg$operators : []))) | ||
}, { | ||
type: _token.TokenType.ASTERISK, | ||
regex: new RegExp("\\*", "y") | ||
}, { | ||
type: _token.TokenType.DOT, | ||
regex: new RegExp("\\.", "y") | ||
}]); | ||
@@ -188,0 +192,0 @@ } // These rules can't be blindly cached as the paramTypesOverrides object |
@@ -16,2 +16,3 @@ "use strict"; | ||
NodeType["array_subscript"] = "array_subscript"; | ||
NodeType["property_access"] = "property_access"; | ||
NodeType["parenthesis"] = "parenthesis"; | ||
@@ -18,0 +19,0 @@ NodeType["between_predicate"] = "between_predicate"; |
@@ -344,2 +344,5 @@ "use strict"; | ||
"name": "expression$subexpression$1", | ||
"symbols": ["between_predicate"] | ||
}, { | ||
"name": "expression$subexpression$1", | ||
"symbols": ["asterisk"] | ||
@@ -358,2 +361,5 @@ }, { | ||
"name": "asteriskless_expression$subexpression$1", | ||
"symbols": ["between_predicate"] | ||
}, { | ||
"name": "asteriskless_expression$subexpression$1", | ||
"symbols": ["comma"] | ||
@@ -369,2 +375,5 @@ }, { | ||
"name": "commaless_expression$subexpression$1", | ||
"symbols": ["between_predicate"] | ||
}, { | ||
"name": "commaless_expression$subexpression$1", | ||
"symbols": ["asterisk"] | ||
@@ -383,2 +392,5 @@ }, { | ||
"name": "simple_expression$subexpression$1", | ||
"symbols": ["property_access"] | ||
}, { | ||
"name": "simple_expression$subexpression$1", | ||
"symbols": ["parenthesis"] | ||
@@ -393,5 +405,2 @@ }, { | ||
"name": "simple_expression$subexpression$1", | ||
"symbols": ["between_predicate"] | ||
}, { | ||
"name": "simple_expression$subexpression$1", | ||
"symbols": ["expression_token"] | ||
@@ -532,2 +541,30 @@ }, { | ||
}, { | ||
"name": "property_access$subexpression$1", | ||
"symbols": ["identifier"] | ||
}, { | ||
"name": "property_access$subexpression$1", | ||
"symbols": ["array_subscript"] | ||
}, { | ||
"name": "property_access", | ||
"symbols": ["simple_expression", lexer.has("DOT") ? { | ||
type: "DOT" | ||
} : DOT, "property_access$subexpression$1"], | ||
"postprocess": // Allowing property to be <array_subscript> is currently a hack. | ||
// A better way would be to allow <property_access> on the left side of array_subscript, | ||
// but we currently can't do that because of another hack that requires | ||
// %ARRAY_IDENTIFIER on the left side of <array_subscript>. | ||
function postprocess(_ref29) { | ||
var _ref30 = _slicedToArray(_ref29, 3), | ||
object = _ref30[0], | ||
dot = _ref30[1], | ||
_ref30$ = _slicedToArray(_ref30[2], 1), | ||
property = _ref30$[0]; | ||
return { | ||
type: _ast.NodeType.property_access, | ||
object: object, | ||
property: property | ||
}; | ||
} | ||
}, { | ||
"name": "between_predicate", | ||
@@ -539,8 +576,8 @@ "symbols": [lexer.has("BETWEEN") ? { | ||
} : AND, "commaless_expression"], | ||
"postprocess": function postprocess(_ref29) { | ||
var _ref30 = _slicedToArray(_ref29, 4), | ||
betweenToken = _ref30[0], | ||
expr1 = _ref30[1], | ||
andToken = _ref30[2], | ||
expr2 = _ref30[3]; | ||
"postprocess": function postprocess(_ref31) { | ||
var _ref32 = _slicedToArray(_ref31, 4), | ||
betweenToken = _ref32[0], | ||
expr1 = _ref32[1], | ||
andToken = _ref32[2], | ||
expr2 = _ref32[3]; | ||
@@ -563,6 +600,6 @@ return { | ||
"symbols": ["comma$subexpression$1"], | ||
"postprocess": function postprocess(_ref31) { | ||
var _ref32 = _slicedToArray(_ref31, 1), | ||
_ref32$ = _slicedToArray(_ref32[0], 1), | ||
token = _ref32$[0]; | ||
"postprocess": function postprocess(_ref33) { | ||
var _ref34 = _slicedToArray(_ref33, 1), | ||
_ref34$ = _slicedToArray(_ref34[0], 1), | ||
token = _ref34$[0]; | ||
@@ -581,6 +618,6 @@ return { | ||
"symbols": ["asterisk$subexpression$1"], | ||
"postprocess": function postprocess(_ref33) { | ||
var _ref34 = _slicedToArray(_ref33, 1), | ||
_ref34$ = _slicedToArray(_ref34[0], 1), | ||
token = _ref34$[0]; | ||
"postprocess": function postprocess(_ref35) { | ||
var _ref36 = _slicedToArray(_ref35, 1), | ||
_ref36$ = _slicedToArray(_ref36[0], 1), | ||
token = _ref36$[0]; | ||
@@ -622,6 +659,6 @@ return { | ||
"symbols": ["operator$subexpression$1"], | ||
"postprocess": function postprocess(_ref35) { | ||
var _ref36 = _slicedToArray(_ref35, 1), | ||
_ref36$ = _slicedToArray(_ref36[0], 1), | ||
token = _ref36$[0]; | ||
"postprocess": function postprocess(_ref37) { | ||
var _ref38 = _slicedToArray(_ref37, 1), | ||
_ref38$ = _slicedToArray(_ref38[0], 1), | ||
token = _ref38$[0]; | ||
@@ -651,6 +688,6 @@ return { | ||
"symbols": ["identifier$subexpression$1"], | ||
"postprocess": function postprocess(_ref37) { | ||
var _ref38 = _slicedToArray(_ref37, 1), | ||
_ref38$ = _slicedToArray(_ref38[0], 1), | ||
token = _ref38$[0]; | ||
"postprocess": function postprocess(_ref39) { | ||
var _ref40 = _slicedToArray(_ref39, 1), | ||
_ref40$ = _slicedToArray(_ref40[0], 1), | ||
token = _ref40$[0]; | ||
@@ -685,6 +722,6 @@ return { | ||
"symbols": ["parameter$subexpression$1"], | ||
"postprocess": function postprocess(_ref39) { | ||
var _ref40 = _slicedToArray(_ref39, 1), | ||
_ref40$ = _slicedToArray(_ref40[0], 1), | ||
token = _ref40$[0]; | ||
"postprocess": function postprocess(_ref41) { | ||
var _ref42 = _slicedToArray(_ref41, 1), | ||
_ref42$ = _slicedToArray(_ref42[0], 1), | ||
token = _ref42$[0]; | ||
@@ -710,6 +747,6 @@ return { | ||
"symbols": ["literal$subexpression$1"], | ||
"postprocess": function postprocess(_ref41) { | ||
var _ref42 = _slicedToArray(_ref41, 1), | ||
_ref42$ = _slicedToArray(_ref42[0], 1), | ||
token = _ref42$[0]; | ||
"postprocess": function postprocess(_ref43) { | ||
var _ref44 = _slicedToArray(_ref43, 1), | ||
_ref44$ = _slicedToArray(_ref44[0], 1), | ||
token = _ref44$[0]; | ||
@@ -769,6 +806,6 @@ return { | ||
"symbols": ["keyword$subexpression$1"], | ||
"postprocess": function postprocess(_ref43) { | ||
var _ref44 = _slicedToArray(_ref43, 1), | ||
_ref44$ = _slicedToArray(_ref44[0], 1), | ||
token = _ref44$[0]; | ||
"postprocess": function postprocess(_ref45) { | ||
var _ref46 = _slicedToArray(_ref45, 1), | ||
_ref46$ = _slicedToArray(_ref46[0], 1), | ||
token = _ref46$[0]; | ||
@@ -782,5 +819,5 @@ return toKeywordNode(token); | ||
} : LINE_COMMENT], | ||
"postprocess": function postprocess(_ref45) { | ||
var _ref46 = _slicedToArray(_ref45, 1), | ||
token = _ref46[0]; | ||
"postprocess": function postprocess(_ref47) { | ||
var _ref48 = _slicedToArray(_ref47, 1), | ||
token = _ref48[0]; | ||
@@ -798,5 +835,5 @@ return { | ||
} : BLOCK_COMMENT], | ||
"postprocess": function postprocess(_ref47) { | ||
var _ref48 = _slicedToArray(_ref47, 1), | ||
token = _ref48[0]; | ||
"postprocess": function postprocess(_ref49) { | ||
var _ref50 = _slicedToArray(_ref49, 1), | ||
token = _ref50[0]; | ||
@@ -803,0 +840,0 @@ return { |
@@ -25,2 +25,3 @@ import { FormatOptions } from "../FormatOptions"; | ||
private formatArraySubscript; | ||
private formatPropertyAccess; | ||
private formatParenthesis; | ||
@@ -27,0 +28,0 @@ private formatBetweenPredicate; |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class BigQueryFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class Db2Formatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class HiveFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class MariaDbFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class MySqlFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class N1qlFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class PlSqlFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class PostgreSqlFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class RedshiftFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class SingleStoreDbFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class SparkFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class SqlFormatter extends Formatter { | ||
static operators: never[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class SqliteFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class TrinoFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
import Formatter from "../../formatter/Formatter"; | ||
import Tokenizer from "../../lexer/Tokenizer"; | ||
export default class TSqlFormatter extends Formatter { | ||
static operators: string[]; | ||
tokenizer(): Tokenizer; | ||
} |
@@ -13,6 +13,4 @@ import { IdentChars, QuoteType, VariableType } from './TokenizerOptions'; | ||
* Builds a RegExp containing all operators for a SQL dialect | ||
* @param {string} monadOperators - concatenated string of all 1-length operators | ||
* @param {string[]} polyadOperators - list of strings of all >1-length operators | ||
*/ | ||
export declare const operator: (monadOperators: string, polyadOperators: string[]) => RegExp; | ||
export declare const operator: (operators: string[]) => RegExp; | ||
/** | ||
@@ -31,4 +29,10 @@ * Builds a RegExp for all Reserved Keywords in a SQL dialect | ||
'[]': string; | ||
'""': string; | ||
"''": string; | ||
'""-qq': string; | ||
'""-bs': string; | ||
'""-qq-bs': string; | ||
'""-raw': string; | ||
"''-qq": string; | ||
"''-bs": string; | ||
"''-qq-bs": string; | ||
"''-raw": string; | ||
$$: string; | ||
@@ -35,0 +39,0 @@ "'''..'''": string; |
@@ -27,2 +27,3 @@ /** Token type enum for all possible Token categories */ | ||
ASTERISK = "ASTERISK", | ||
DOT = "DOT", | ||
OPEN_PAREN = "OPEN_PAREN", | ||
@@ -29,0 +30,0 @@ CLOSE_PAREN = "CLOSE_PAREN", |
@@ -8,2 +8,3 @@ import { TokenType } from "../lexer/token"; | ||
array_subscript = "array_subscript", | ||
property_access = "property_access", | ||
parenthesis = "parenthesis", | ||
@@ -73,2 +74,7 @@ between_predicate = "between_predicate", | ||
}; | ||
export declare type PropertyAccessNode = { | ||
type: NodeType.property_access; | ||
object: AstNode; | ||
property: IdentifierNode; | ||
}; | ||
export declare type IdentifierNode = { | ||
@@ -105,2 +111,2 @@ type: NodeType.identifier; | ||
}; | ||
export declare type AstNode = ClauseNode | SetOperationNode | FunctionCallNode | ArraySubscriptNode | ParenthesisNode | BetweenPredicateNode | LimitClauseNode | AllColumnsAsteriskNode | LiteralNode | IdentifierNode | KeywordNode | ParameterNode | OperatorNode | CommaNode | LineCommentNode | BlockCommentNode; | ||
export declare type AstNode = ClauseNode | SetOperationNode | FunctionCallNode | ArraySubscriptNode | PropertyAccessNode | ParenthesisNode | BetweenPredicateNode | LimitClauseNode | AllColumnsAsteriskNode | LiteralNode | IdentifierNode | KeywordNode | ParameterNode | OperatorNode | CommaNode | LineCommentNode | BlockCommentNode; |
import { FormatFn } from "../../src/sqlFormatter"; | ||
declare type IdentType = '""' | '``' | '[]' | 'U&""'; | ||
declare type IdentType = '""-qq' | '``' | '[]' | 'U&""'; | ||
export default function supportsIdentifiers(format: FormatFn, identifierTypes: IdentType[]): void; | ||
export {}; |
import { FormatFn } from "../../src/sqlFormatter"; | ||
declare type StringType = '""' | "''" | 'U&""' | "U&''" | "N''" | "X''" | 'X""' | "B''" | 'B""' | "R''" | 'R""'; | ||
declare type StringType = '""-qq' | '""-bs' | "''-qq" | "''-bs" | "U&''" | "N''" | "X''" | 'X""' | "B''" | 'B""' | "R''" | 'R""'; | ||
export default function supportsStrings(format: FormatFn, stringTypes: StringType[]): void; | ||
export {}; |
{ | ||
"name": "sql-formatter", | ||
"version": "10.3.0", | ||
"version": "10.4.0", | ||
"description": "Format whitespace in a SQL query to make it more readable", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
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
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
1953567
8533