Skip to content

Commit 3fe229e

Browse files
v5.1.1 (#81)
1 parent 047084b commit 3fe229e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1135
-354
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# CHANGELOG
22

3+
## [5.1.1] : 2022-04-06
4+
5+
### Updated
6+
7+
- restored itemCount setting for VScode extension
8+
- added JSDocs for all files
9+
- added conditional skips for Jest tests
10+
- added missing BigQuery, hive from demo page language dropdown
11+
12+
### Fixed
13+
14+
- fixed bug with CASE and Inline Block interaction
15+
- fixed bug with END not adding spacings before END
16+
- fixed bug with CommaPosition.before when the line had no preceding whitespace
17+
- fixed bug where AS in CAST functions would get deleted when AliasAs.never
18+
- fixed bug where AS would get deleted in CTE definition when AliasAs.never
19+
320
## [5.1.0] : 2021-12-21
421

522
### Known Issues

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ For those who have admin access on the repo, the new release publish flow is as
5454

5555
- `release-it` (bumps version, git tag, git release, npm release)
5656
- bump VSCode version + prettier-sql dependency version (can be done beforehand, must be done before push)
57-
- `git subtree push --prefix static origin gh-pages` && `gh pages deploy` (pushes demo page to GH pages)
57+
- `git subtree push --prefix static origin gh-pages` (pushes demo page to GH pages)
5858
- `git dio develop` (moves origin/develop branch head to master)
59+
- alias for `git push --force-with-lease origin HEAD:develop`
5960
- `vscode deploy` (run within vscode/ subrepo, deploys VSCode Extension)
61+
- `npx vsce publish` (required authenticated PAT (Personal Access Token))
6062

6163
# Contributors
6264

DOC.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Prettier-SQL
2+
3+
## Overview:
4+
5+
This formatter generally follows this flow:
6+
7+
- `<sql>.formatter.ts` files are created for each support dialect that defined a mostly exhaustive list of Reserved Keywords\*
8+
- this formatter class is then passed to the lexer, which tokenises the SQL input string and produces a token stream\*\*
9+
- the token stream is then directly formatted sequentially by the `format()` method, without a parsing step\*\*\*
10+
11+
\*some more edge case work needs to be done regarding identifying keywords that are multiple words instead of single words
12+
13+
\*\*this tokenizer is set to be replaced in the v5.2 release (Moo)
14+
15+
\*\*\*a parser is set to be added in the future with the v6 release (Nearley)
16+
17+
## Tokenizer:
18+
19+
The tokenizer consumes the lists of tokens from the formatter class files, joined them into respective regular expressions. \
20+
These regular expressions are then tested in order of priority, allowing Reserved Keywords and Reserved Commands to be matched before common identifiers or operators.
21+
22+
The current priority order is:
23+
24+
- Line Comment (denotes comments across the entire line)
25+
- Block Comment (denotes comments within a block)
26+
- Strings (only specific tokens beginning and ending with the supported string delimiters)
27+
- Block Start tokens (such as Left Parenthesis, Left Bracket, Left Brace, and CASE)
28+
- Block End tokens (such as Right Parenthesis, Right Bracket, Right Brace, and END)
29+
- Placeholder tokens (used for variable substitution)
30+
- Numbers (must match a common numeric format, such as floats or scientific notation)
31+
- Reserved words (denotes words that are reserved in the SQL dialect)
32+
33+
- Reserved Commands (begins its own clause, such as `SELECT`)
34+
- Reserved Binary Commands (connect two adjacent clauses, such as joins or set operations)
35+
- Reserved Dependent Clauses (keywords that are dependent on the previous clause, such as `ON` for joins or `WHEN` and `THEN` for CASE)
36+
- Reserved Logical Operator (boolean operators such as `AND` and `OR`)
37+
- Reserved Keywords/Functions (other reserved words)
38+
39+
- Word tokens (aka common identifiers)
40+
- Operators (any supported operators comprised of special characters)

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<a href='https://github.com/inferrinizzard/prettier-sql'><img src="static/prettier-sql-clean.svg" width="128"/></a>
22

3-
# Prettier SQL [![NPM version](https://img.shields.io/npm/v/prettier-sql.svg)](https://npmjs.com/package/prettier-sql) ![GitHub Workflow Status (event)](https://img.shields.io/github/workflow/status/inferrinizzard/prettier-sql/coveralls/master?label=Build&logo=Github) ![Coveralls](https://img.shields.io/coveralls/github/inferrinizzard/prettier-sql?branch=master&label=Coverage&logo=coveralls&style=plastic)
3+
# Prettier SQL [![NPM version](https://img.shields.io/npm/v/prettier-sql.svg)](https://npmjs.com/package/prettier-sql) ![GitHub Workflow Status (event)](https://img.shields.io/github/workflow/status/inferrinizzard/prettier-sql/coveralls/master?label=Build&logo=Github) ![Coveralls](https://img.shields.io/coveralls/github/inferrinizzard/prettier-sql?branch=master&label=Coverage&logo=coveralls&style=plastic) [![VSCode](https://img.shields.io/visual-studio-marketplace/v/inferrinizzard.prettier-sql-vscode?label=vscode)](https://marketplace.visualstudio.com/items?itemName=inferrinizzard.prettier-sql-vscode)
44

55
## **Prettier SQL** is a JavaScript library for pretty-printing SQL queries.
66

@@ -31,6 +31,7 @@ It does not support:
3131
# Table of contents
3232

3333
- [Install](#install)
34+
- [Documentation](#documentation)
3435
- [Usage](#usage)
3536
- [Usage as library](#usage-as-library)
3637
- [Usage from command line](#usage-from-command-line)
@@ -52,6 +53,10 @@ Also available with yarn:
5253
yarn add prettier-sql
5354
```
5455

56+
## Documentation
57+
58+
You can read more about how the library works in [DOC.md](DOC.md)
59+
5560
## Usage
5661

5762
### Usage as library

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"@babel/plugin-proposal-class-properties": "^7.10.4",
6767
"@babel/preset-env": "^7.10.4",
6868
"@babel/preset-typescript": "^7.15.0",
69+
"@jest/globals": "^27.5.1",
6970
"@types/babel__core": "^7.1.15",
7071
"@typescript-eslint/eslint-plugin": "^4.31.2",
7172
"@typescript-eslint/parser": "^4.32.0",

0 commit comments

Comments
 (0)