rawsql-ts 0.24.0 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.min.js +5 -5
- package/dist/esm/index.min.js.map +4 -4
- package/dist/esm/parsers/SqlPrintTokenParser.d.ts +11 -0
- package/dist/esm/parsers/SqlPrintTokenParser.js +17 -6
- package/dist/esm/parsers/SqlPrintTokenParser.js.map +1 -1
- package/dist/esm/parsers/SqlTokenizer.js +2 -2
- package/dist/esm/parsers/SqlTokenizer.js.map +1 -1
- package/dist/esm/tokenReaders/FunctionTokenReader.d.ts +1 -0
- package/dist/esm/tokenReaders/FunctionTokenReader.js +7 -0
- package/dist/esm/tokenReaders/FunctionTokenReader.js.map +1 -1
- package/dist/esm/tokenReaders/PostgresFunctionTokenReader.d.ts +5 -0
- package/dist/esm/tokenReaders/PostgresFunctionTokenReader.js +12 -0
- package/dist/esm/tokenReaders/PostgresFunctionTokenReader.js.map +1 -0
- package/dist/esm/transformers/SqlFormatter.d.ts +5 -1
- package/dist/esm/transformers/SqlFormatter.js +3 -3
- package/dist/esm/transformers/SqlFormatter.js.map +1 -1
- package/dist/index.min.js +5 -5
- package/dist/index.min.js.map +4 -4
- package/dist/parsers/SqlPrintTokenParser.js +17 -6
- package/dist/parsers/SqlPrintTokenParser.js.map +1 -1
- package/dist/parsers/SqlTokenizer.js +2 -2
- package/dist/parsers/SqlTokenizer.js.map +1 -1
- package/dist/src/parsers/SqlPrintTokenParser.d.ts +11 -0
- package/dist/src/tokenReaders/FunctionTokenReader.d.ts +1 -0
- package/dist/src/tokenReaders/PostgresFunctionTokenReader.d.ts +5 -0
- package/dist/src/transformers/SqlFormatter.d.ts +5 -1
- package/dist/tokenReaders/FunctionTokenReader.js +7 -0
- package/dist/tokenReaders/FunctionTokenReader.js.map +1 -1
- package/dist/tokenReaders/PostgresFunctionTokenReader.js +16 -0
- package/dist/tokenReaders/PostgresFunctionTokenReader.js.map +1 -0
- package/dist/transformers/SqlFormatter.js +4 -2
- package/dist/transformers/SqlFormatter.js.map +1 -1
- package/dist/tsconfig.browser.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -157,7 +157,7 @@ class SqlPrintTokenParser {
|
|
|
157
157
|
return this._selfHandlingComponentTypes;
|
|
158
158
|
}
|
|
159
159
|
constructor(options) {
|
|
160
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
160
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
161
161
|
this.handlers = new Map();
|
|
162
162
|
this.index = 1;
|
|
163
163
|
this.joinConditionContexts = [];
|
|
@@ -177,7 +177,9 @@ class SqlPrintTokenParser {
|
|
|
177
177
|
});
|
|
178
178
|
this.castStyle = (_j = options === null || options === void 0 ? void 0 : options.castStyle) !== null && _j !== void 0 ? _j : 'standard';
|
|
179
179
|
this.constraintStyle = (_k = options === null || options === void 0 ? void 0 : options.constraintStyle) !== null && _k !== void 0 ? _k : 'postgres';
|
|
180
|
-
this.
|
|
180
|
+
this.sourceAliasStyle = (_l = options === null || options === void 0 ? void 0 : options.sourceAliasStyle) !== null && _l !== void 0 ? _l : 'as';
|
|
181
|
+
this.orderByDefaultDirectionStyle = (_m = options === null || options === void 0 ? void 0 : options.orderByDefaultDirectionStyle) !== null && _m !== void 0 ? _m : 'omit';
|
|
182
|
+
this.normalizeJoinConditionOrder = (_o = options === null || options === void 0 ? void 0 : options.joinConditionOrderByDeclaration) !== null && _o !== void 0 ? _o : false;
|
|
181
183
|
this.handlers.set(ValueComponent_1.ValueList.kind, (expr) => this.visitValueList(expr));
|
|
182
184
|
this.handlers.set(ValueComponent_1.ColumnReference.kind, (expr) => this.visitColumnReference(expr));
|
|
183
185
|
this.handlers.set(ValueComponent_1.QualifiedName.kind, (expr) => this.visitQualifiedName(expr));
|
|
@@ -403,6 +405,10 @@ class SqlPrintTokenParser {
|
|
|
403
405
|
token.innerTokens.push(SqlPrintTokenParser.SPACE_TOKEN);
|
|
404
406
|
token.innerTokens.push(new SqlPrintToken_1.SqlPrintToken(SqlPrintToken_1.SqlPrintTokenType.keyword, 'desc'));
|
|
405
407
|
}
|
|
408
|
+
else if (this.orderByDefaultDirectionStyle === 'explicit') {
|
|
409
|
+
token.innerTokens.push(SqlPrintTokenParser.SPACE_TOKEN);
|
|
410
|
+
token.innerTokens.push(new SqlPrintToken_1.SqlPrintToken(SqlPrintToken_1.SqlPrintTokenType.keyword, 'asc'));
|
|
411
|
+
}
|
|
406
412
|
if (arg.nullsPosition) {
|
|
407
413
|
if (arg.nullsPosition === Clause_1.NullsSortDirection.First) {
|
|
408
414
|
token.innerTokens.push(SqlPrintTokenParser.SPACE_TOKEN);
|
|
@@ -1772,8 +1778,7 @@ class SqlPrintTokenParser {
|
|
|
1772
1778
|
return token;
|
|
1773
1779
|
}
|
|
1774
1780
|
token.innerTokens.push(SqlPrintTokenParser.SPACE_TOKEN);
|
|
1775
|
-
|
|
1776
|
-
token.innerTokens.push(SqlPrintTokenParser.SPACE_TOKEN);
|
|
1781
|
+
this.appendSourceAliasKeyword(token);
|
|
1777
1782
|
// exclude column aliases
|
|
1778
1783
|
token.innerTokens.push(arg.aliasExpression.accept(this));
|
|
1779
1784
|
return token;
|
|
@@ -1781,13 +1786,19 @@ class SqlPrintTokenParser {
|
|
|
1781
1786
|
else {
|
|
1782
1787
|
// For other source types, just print the alias
|
|
1783
1788
|
token.innerTokens.push(SqlPrintTokenParser.SPACE_TOKEN);
|
|
1784
|
-
|
|
1785
|
-
token.innerTokens.push(SqlPrintTokenParser.SPACE_TOKEN);
|
|
1789
|
+
this.appendSourceAliasKeyword(token);
|
|
1786
1790
|
// included column aliases
|
|
1787
1791
|
token.innerTokens.push(arg.aliasExpression.accept(this));
|
|
1788
1792
|
return token;
|
|
1789
1793
|
}
|
|
1790
1794
|
}
|
|
1795
|
+
appendSourceAliasKeyword(token) {
|
|
1796
|
+
if (this.sourceAliasStyle === 'implicit') {
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
token.innerTokens.push(new SqlPrintToken_1.SqlPrintToken(SqlPrintToken_1.SqlPrintTokenType.keyword, 'as'));
|
|
1800
|
+
token.innerTokens.push(SqlPrintTokenParser.SPACE_TOKEN);
|
|
1801
|
+
}
|
|
1791
1802
|
visitFromClause(arg) {
|
|
1792
1803
|
// Build a declaration order map so JOIN ON operands can be normalized later.
|
|
1793
1804
|
let contextPushed = false;
|