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

sql-formatter

Package Overview
Dependencies
Maintainers
2
Versions
148
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 6.0.0-beta.3 to 6.0.0-beta.4

45

lib/core/formatAliasPositions.js

@@ -50,27 +50,36 @@ "use strict";

aliasLines.push(lines[i]);
}
} // break lines into alias with optional AS, and all preceding text
var splitLines = aliasLines.map(function (line) {
return line.split(/(?<=[^\s]+) (AS )?(?=[^\s]+,?$)/i);
}) // break lines into alias with optional AS, and all preceding text
.map(function (slugs) {
return {
precedingText: slugs[0],
// always first split
alias: slugs.length > 1 ? slugs[slugs.length - 1] : undefined,
// always last in split
as: slugs.length === 3 ? slugs[1] : undefined // 2nd if AS is present, else omitted
line: line,
matches: line.match(/(^.*?\S) (AS )?(\S+,?$)/i)
};
}).map(function (_ref) {
var line = _ref.line,
matches = _ref.matches;
if (!matches) {
return {
precedingText: line
};
}
return {
precedingText: matches[1],
as: matches[2],
alias: matches[3]
};
});
var aliasMaxLength = (0, _utils.maxLength)(splitLines.map(function (_ref) {
var precedingText = _ref.precedingText;
}); // get longest of precedingText, trim trailing comma for non-alias columns
var aliasMaxLength = (0, _utils.maxLength)(splitLines.map(function (_ref2) {
var precedingText = _ref2.precedingText;
return precedingText.replace(/\s*,\s*$/, '');
}) // get longest of precedingText, trim trailing comma for non-alias columns
); // re-construct line, aligning by inserting space before AS or alias
})); // re-construct line, aligning by inserting space before AS or alias
aliasLines = splitLines.map(function (_ref2) {
var precedingText = _ref2.precedingText,
as = _ref2.as,
alias = _ref2.alias;
aliasLines = splitLines.map(function (_ref3) {
var precedingText = _ref3.precedingText,
as = _ref3.as,
alias = _ref3.alias;
return precedingText + (alias ? ' '.repeat(aliasMaxLength - precedingText.length + 1) + (as !== null && as !== void 0 ? as : '') + alias : '');

@@ -77,0 +86,0 @@ });

2

package.json
{
"name": "sql-formatter",
"version": "6.0.0-beta.3",
"version": "6.0.0-beta.4",
"description": "Format whitespace in a SQL query to make it more readable",

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

@@ -7,5 +7,2 @@ <a href='https://github.com/zeroturnaround/sql-formatter'><img src="static/prettier-sql-clean.svg" width="128"/></a>

**Note.** The docs here are for the latest dev version.
For the latest release, see [v4.0.2](https://github.com/zeroturnaround/sql-formatter/tree/v4.0.2).
It started as a port of a [PHP Library][], but has since considerably diverged.

@@ -12,0 +9,0 @@

Sorry, the diff of this file is too big to display

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

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