mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-19 16:16:45 +00:00
feat(format): default to dbx layout and align fields
This commit is contained in:
@@ -28,9 +28,9 @@ MongoDB 查询编辑器使用单独的 Mongo Shell 格式化器,不使用本
|
||||
|
||||
## 默认风格
|
||||
|
||||
默认的 `dbx` 排版规则:能放下的语句保持一行,放不下的按子句逐行展开,子句的后续元素与第一个元素对齐;条件的逻辑操作符放在续行行首;`CREATE TABLE` 的列定义按列对齐。下面的设置用于调整这些规则,**恢复默认值**会回到该风格。
|
||||
默认的 `dbx` 排版采用 DBX 布局:显式 `AS` 别名对齐,`FROM` 与表名同行。短查询仍会保持紧凑,`CREATE TABLE` 定义按列对齐。`classic` 使用 sql-formatter 上游的排版。点击**恢复默认值**会回到当前默认风格。
|
||||
|
||||
把 **排版风格** 设为 `classic` 会改用 sql-formatter 自身的排版,也就是 v0.6.16 之前 DBX 的默认样式。v0.6.16 同时还改过两项默认值,因此还要把 **表达式宽度** 设为 `50`、**FROM 子句布局** 设为换行,才能还原旧输出;等价的 JSON 是 `"expressionWidth": 50`、`"fromClauseLayout": "newLine"`,与 `"layoutStyle": "classic"` 并列。除 Oracle 外结果与 v0.6.15 一致:Oracle 的字节/多字节函数变体(`SUBSTRB`、`INSTR2`、`LENGTHB` 等同族函数)保留较新的修复,会被规范为函数形式。
|
||||
`classic` 使用 sql-formatter 自身的排版,也是 v0.6.16 之前 DBX 的默认风格。如需精确还原此前输出,可把**表达式宽度**设为 `50`、**FROM 子句布局**设为换行;JSON 中对应为 `"expressionWidth": 50`、`"fromClauseLayout": "newLine"`,与 `"layoutStyle": "classic"` 并列。除 Oracle 外结果与 v0.6.15 一致:Oracle 的字节/多字节函数变体(`SUBSTRB`、`INSTR2`、`LENGTHB` 等同族函数)保留较新的修复,会被规范为函数形式。
|
||||
|
||||
切换排版风格只切引擎,不会顺带改写其它选项。两种缩进样式(`tabularLeft`、`tabularRight`)在两种风格下都使用 sql-formatter 自身的排版。
|
||||
|
||||
@@ -40,7 +40,7 @@ MongoDB 查询编辑器使用单独的 Mongo Shell 格式化器,不使用本
|
||||
|
||||
| 选项 | 可用值或作用 |
|
||||
| --- | --- |
|
||||
| 排版风格 | `dbx`(DBX 自研排版,默认)或 `classic`(sql-formatter 上游排版,同 v0.6.15) |
|
||||
| 排版风格 | `dbx`(DBX 排版,默认)或 `classic`(sql-formatter 上游排版) |
|
||||
| 关键字、数据类型、函数、标识符大小写 | `upper`、`lower`、`preserve` |
|
||||
| 缩进样式 | `standard`、`tabularLeft`、`tabularRight` |
|
||||
| 缩进字符 | 空格或 Tab |
|
||||
|
||||
@@ -28,9 +28,9 @@ The MongoDB query editor uses a separate Mongo Shell formatter rather than this
|
||||
|
||||
## Default Style
|
||||
|
||||
The default `dbx` layout keeps a statement that fits the width on one line, puts each clause of a longer one on its own line, and aligns a clause's remaining elements under its first element. Conditions keep their logical operators at the start of the continuation line, and `CREATE TABLE` definitions are aligned on a column grid. The settings below change those rules; **Restore Defaults** returns to this style.
|
||||
The default `dbx` layout uses DBX's layout rules: explicit `AS` aliases align, and `FROM` stays with its source. Short queries stay compact, and `CREATE TABLE` definitions align on a column grid. `classic` uses sql-formatter's upstream layout. **Restore Defaults** returns to the current default style.
|
||||
|
||||
Set **Layout style** to `classic` to use sql-formatter's own layout instead — the default DBX shipped before v0.6.16. v0.6.16 also changed two option defaults, so also set **Expression width** to `50` and **FROM clause layout** to the new-line value to reproduce the old output; the JSON equivalent is `"expressionWidth": 50` and `"fromClauseLayout": "newLine"`, next to `"layoutStyle": "classic"`. The result matches v0.6.15 except on Oracle, where the byte/multibyte function variants (`SUBSTRB`, `INSTR2`, `LENGTHB` and the rest of that family) keep the newer fix that normalizes them as functions.
|
||||
`classic` uses sql-formatter's own layout and is also the DBX default from before v0.6.16. To reproduce that earlier output exactly, set **Expression width** to `50` and **FROM clause layout** to the new-line value; the JSON equivalent is `"expressionWidth": 50` and `"fromClauseLayout": "newLine"` next to `"layoutStyle": "classic"`. The result matches v0.6.15 except on Oracle, where the byte/multibyte function variants (`SUBSTRB`, `INSTR2`, `LENGTHB` and the rest of that family) keep the newer fix that normalizes them as functions.
|
||||
|
||||
Switching the layout style only changes the engine; it never rewrites the other options. The two indent styles (`tabularLeft`, `tabularRight`) always use sql-formatter's own layout, in either mode.
|
||||
|
||||
@@ -40,7 +40,7 @@ Open **Settings → SQL Formatter**. Form mode exposes:
|
||||
|
||||
| Option | Values or behavior |
|
||||
| --- | --- |
|
||||
| Layout style | `dbx` (DBX's own layout, default) or `classic` (sql-formatter's upstream layout, as in v0.6.15) |
|
||||
| Layout style | `dbx` (DBX layout, default) or `classic` (sql-formatter's upstream layout) |
|
||||
| Keyword, data type, function, and identifier case | `upper`, `lower`, or `preserve` |
|
||||
| Indent style | `standard`, `tabularLeft`, or `tabularRight` |
|
||||
| Indentation | Spaces or tabs |
|
||||
|
||||
Reference in New Issue
Block a user