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

sql-formatter

Package Overview
Dependencies
Maintainers
2
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-formatter - npm Package Compare versions

Comparing version 10.0.0-beta.1 to 10.0.0

3

lib/languages/bigquery/bigquery.formatter.js

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

reservedFunctionNames: _bigquery2.functions,
openParens: ['(', '['],
closeParens: [')', ']'],
extraParens: ['[]'],
stringTypes: [// The triple-quoted strings are listed first, so they get matched first.

@@ -105,0 +104,0 @@ // Otherwise the first two quotes of """ will get matched as an empty "" string.

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

reservedFunctionNames: _hive.functions,
openParens: ['(', '['],
closeParens: [')', ']'],
extraParens: ['[]'],
stringTypes: ['""', "''"],

@@ -94,0 +93,0 @@ identTypes: ['``'],

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

identTypes: ['``'],
openParens: ['(', '[', '{'],
closeParens: [')', ']', '}'],
extraParens: ['[]', '{}'],
paramTypes: {

@@ -89,0 +88,0 @@ positional: true,

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

reservedFunctionNames: _postgresql.functions,
openParens: ['(', '['],
closeParens: [')', ']'],
extraParens: ['[]'],
stringTypes: ['$$', {

@@ -102,0 +101,0 @@ quote: "''",

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

reservedFunctionNames: _spark2.functions,
openParens: ['(', '['],
closeParens: [')', ']'],
extraParens: ['[]'],
stringTypes: [{

@@ -99,0 +98,0 @@ quote: "''",

@@ -87,5 +87,7 @@ "use strict";

reservedFunctionNames: _trino.functions,
// Trino also supports {- ... -} parenthesis.
// The formatting of these currently works out as a result of { and -
// not getting a space added in-between.
// https://trino.io/docs/current/sql/match-recognize.html#row-pattern-syntax
openParens: ['(', '[', '{', '{-'],
closeParens: [')', ']', '}', '-}'],
extraParens: ['[]', '{}'],
// https://trino.io/docs/current/language/types.html#string

@@ -92,0 +94,0 @@ // https://trino.io/docs/current/language/types.html#varbinary

@@ -20,9 +20,17 @@ "use strict";

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

@@ -37,4 +45,3 @@ /**

/**
* Builds a RegExp for matching parenthesis patterns, escaping them with `escapeParen`
* @param {string[]} parens - list of strings that denote parenthesis patterns
* Builds a RegExp for matching either open- or close-parenthesis patterns
*/

@@ -45,4 +52,9 @@

var parenthesis = function parenthesis(parens) {
return (0, _regexUtil.patternToRegex)(parens.map(_regexUtil.escapeParen).join('|'));
var parenthesis = function parenthesis(kind) {
var extraParens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var index = kind === 'open' ? 0 : 1;
var parens = ['()'].concat(_toConsumableArray(extraParens)).map(function (pair) {
return pair[index];
});
return (0, _regexUtil.patternToRegex)(parens.map(_regexUtil.escapeRegExp).join('|'));
};

@@ -49,0 +61,0 @@ /**

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

});
exports.withDashes = exports.toCaseInsensitivePattern = exports.prefixesPattern = exports.patternToRegex = exports.escapeRegExp = exports.escapeParen = exports.WHITESPACE_REGEX = void 0;
exports.withDashes = exports.toCaseInsensitivePattern = exports.prefixesPattern = exports.patternToRegex = exports.escapeRegExp = exports.WHITESPACE_REGEX = void 0;

@@ -30,19 +30,5 @@ // Escapes regex special chars

};
/** Escapes paren characters for RegExp patterns */
exports.toCaseInsensitivePattern = toCaseInsensitivePattern;
var escapeParen = function escapeParen(paren) {
if (paren.length === 1) {
// A single punctuation character
return escapeRegExp(paren);
} else {
// longer word
return '\\b' + escapeRegExp(paren) + '\\b';
}
};
exports.escapeParen = escapeParen;
var withDashes = function withDashes(pattern) {

@@ -49,0 +35,0 @@ return pattern + '(?:-' + pattern + ')*';

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

value: function buildDialectRules(cfg) {
var _cfg$lineCommentTypes, _cfg$openParens, _cfg$closeParens, _cfg$reservedPhrases, _cfg$operators, _this$validRules;
var _cfg$lineCommentTypes, _cfg$reservedPhrases, _cfg$operators, _this$validRules;

@@ -89,8 +89,2 @@ return this.validRules((_this$validRules = {}, _defineProperty(_this$validRules, _token.TokenType.BLOCK_COMMENT, {

regex: regex.lineComment((_cfg$lineCommentTypes = cfg.lineCommentTypes) !== null && _cfg$lineCommentTypes !== void 0 ? _cfg$lineCommentTypes : ['--'])
}), _defineProperty(_this$validRules, _token.TokenType.COMMA, {
regex: new RegExp("[,]", "y")
}), _defineProperty(_this$validRules, _token.TokenType.OPEN_PAREN, {
regex: regex.parenthesis((_cfg$openParens = cfg.openParens) !== null && _cfg$openParens !== void 0 ? _cfg$openParens : ['('])
}), _defineProperty(_this$validRules, _token.TokenType.CLOSE_PAREN, {
regex: regex.parenthesis((_cfg$closeParens = cfg.closeParens) !== null && _cfg$closeParens !== void 0 ? _cfg$closeParens : [')'])
}), _defineProperty(_this$validRules, _token.TokenType.QUOTED_IDENTIFIER, {

@@ -153,2 +147,8 @@ regex: regex.string(cfg.identTypes)

regex: new RegExp(";", "y")
}), _defineProperty(_this$validRules, _token.TokenType.COMMA, {
regex: new RegExp("[,]", "y")
}), _defineProperty(_this$validRules, _token.TokenType.OPEN_PAREN, {
regex: regex.parenthesis('open', cfg.extraParens)
}), _defineProperty(_this$validRules, _token.TokenType.CLOSE_PAREN, {
regex: regex.parenthesis('close', cfg.extraParens)
}), _defineProperty(_this$validRules, _token.TokenType.OPERATOR, {

@@ -155,0 +155,0 @@ regex: regex.operator('+-/%&|^><=.:$@#?~!', ['<>', '<=', '>=', '!='].concat(_toConsumableArray((_cfg$operators = cfg.operators) !== null && _cfg$operators !== void 0 ? _cfg$operators : [])))

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

value: function getNextToken(previousToken) {
return this.matchToken(_token2.TokenType.BLOCK_COMMENT) || this.matchToken(_token2.TokenType.LINE_COMMENT) || this.matchToken(_token2.TokenType.COMMA) || this.matchToken(_token2.TokenType.OPEN_PAREN) || this.matchToken(_token2.TokenType.CLOSE_PAREN) || this.matchToken(_token2.TokenType.QUOTED_IDENTIFIER) || this.matchToken(_token2.TokenType.NUMBER) || this.matchReservedWordToken(previousToken) || this.matchPlaceholderToken(_token2.TokenType.NAMED_PARAMETER) || this.matchPlaceholderToken(_token2.TokenType.QUOTED_PARAMETER) || this.matchPlaceholderToken(_token2.TokenType.NUMBERED_PARAMETER) || this.matchPlaceholderToken(_token2.TokenType.POSITIONAL_PARAMETER) || this.matchToken(_token2.TokenType.VARIABLE) || this.matchToken(_token2.TokenType.STRING) || this.matchToken(_token2.TokenType.IDENTIFIER) || this.matchToken(_token2.TokenType.DELIMITER) || this.matchToken(_token2.TokenType.OPERATOR) || this.matchToken(_token2.TokenType.ASTERISK);
return this.matchToken(_token2.TokenType.BLOCK_COMMENT) || this.matchToken(_token2.TokenType.LINE_COMMENT) || this.matchToken(_token2.TokenType.QUOTED_IDENTIFIER) || this.matchToken(_token2.TokenType.NUMBER) || this.matchReservedWordToken(previousToken) || this.matchPlaceholderToken(_token2.TokenType.NAMED_PARAMETER) || this.matchPlaceholderToken(_token2.TokenType.QUOTED_PARAMETER) || this.matchPlaceholderToken(_token2.TokenType.NUMBERED_PARAMETER) || this.matchPlaceholderToken(_token2.TokenType.POSITIONAL_PARAMETER) || this.matchToken(_token2.TokenType.VARIABLE) || this.matchToken(_token2.TokenType.STRING) || this.matchToken(_token2.TokenType.IDENTIFIER) || this.matchToken(_token2.TokenType.DELIMITER) || this.matchToken(_token2.TokenType.COMMA) || this.matchToken(_token2.TokenType.OPEN_PAREN) || this.matchToken(_token2.TokenType.CLOSE_PAREN) || this.matchToken(_token2.TokenType.OPERATOR) || this.matchToken(_token2.TokenType.ASTERISK);
}

@@ -96,0 +96,0 @@ }, {

@@ -8,6 +8,5 @@ import type { IdentChars, QuoteType, VariableType } from './TokenizerOptions';

/**
* Builds a RegExp for matching parenthesis patterns, escaping them with `escapeParen`
* @param {string[]} parens - list of strings that denote parenthesis patterns
* Builds a RegExp for matching either open- or close-parenthesis patterns
*/
export declare const parenthesis: (parens: string[]) => RegExp;
export declare const parenthesis: (kind: 'open' | 'close', extraParens?: ('[]' | '{}')[]) => RegExp;
/**

@@ -14,0 +13,0 @@ * Builds a RegExp containing all operators for a SQL dialect

@@ -6,5 +6,3 @@ import type { PrefixedQuoteType } from './TokenizerOptions';

export declare const toCaseInsensitivePattern: (prefix: string) => string;
/** Escapes paren characters for RegExp patterns */
export declare const escapeParen: (paren: string) => string;
export declare const withDashes: (pattern: string) => string;
export declare const prefixesPattern: ({ prefixes, requirePrefix }: PrefixedQuoteType) => string;

@@ -39,4 +39,3 @@ import { quotePatterns } from "./regexFactory";

variableTypes?: VariableType[];
openParens?: ('(' | '[' | '{' | '{-')[];
closeParens?: (')' | ']' | '}' | '-}')[];
extraParens?: ('[]' | '{}')[];
paramTypes?: ParamTypes;

@@ -43,0 +42,0 @@ lineCommentTypes?: string[];

{
"name": "sql-formatter",
"version": "10.0.0-beta.1",
"version": "10.0.0",
"description": "Format whitespace in a SQL query to make it more readable",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -160,3 +160,3 @@ <a href='https://github.com/sql-formatter-org/sql-formatter'><img src="static/prettier-sql-clean.svg" width="128"/></a>

- [**`params`**](docs/params.md) collection of values for placeholder replacement.
- [**`paramsTypes`**](docs/paramTypes.md) specifies parameter placeholders types to support.
- [**`paramTypes`**](docs/paramTypes.md) specifies parameter placeholders types to support.

@@ -163,0 +163,0 @@ ### Usage without NPM

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

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