Skip to content

Commit

Permalink
Merge branch 'sql-parser-cst-0.27.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nene committed Feb 7, 2024
2 parents d5555b5 + 063c40a commit 65b9dcd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"dependencies": {
"prettier": "^3.0.3",
"sql-parser-cst": "^0.26.0"
"sql-parser-cst": "^0.27.0"
},
"devDependencies": {
"@types/jest": "^29.2.5",
Expand Down
7 changes: 5 additions & 2 deletions src/syntax/alter_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AllAlterActionNodes } from "sql-parser-cst";
import { CstToDocMap } from "../CstToDocMap";
import { group, join, line } from "../print_utils";

export const alterActionMap: CstToDocMap<AllAlterActionNodes> = {
export const alterActionMap: Partial<CstToDocMap<AllAlterActionNodes>> = {
alter_action_rename: (print) => print.spaced(["renameKw", "newName"]),
alter_action_rename_column: (print) =>
print.spaced(["renameKw", "ifExistsKw", "oldName", "toKw", "newName"]),
Expand All @@ -14,7 +14,10 @@ export const alterActionMap: CstToDocMap<AllAlterActionNodes> = {
print.spaced(["setKw", "options"]),
alter_action_set_default_collate: (print) =>
print.spaced(["setDefaultCollateKw", "collation"]),
alter_action_add_constraint: (print) => print.spaced(["addKw", "constraint"]),
alter_action_add_constraint: (print) =>
print.spaced(["addKw", "name", "constraint", "modifiers"]),
alter_action_add_constraint_constraint_name: (print) =>
print.spaced(["constraintKw", "name"]),
alter_action_drop_constraint: (print) =>
print.spaced([
"dropConstraintKw",
Expand Down
3 changes: 0 additions & 3 deletions src/syntax/constraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export const constraintMap: CstToDocMap<AllConstraintNodes> = {
return baseDoc;
}
},
index_specification: (print) =>
print.spaced(["expr", "opclass", "direction", "nullHandlingKw"]),
referential_action: (print) =>
print.spaced(["onKw", "eventKw", "actionKw", "columns"]),
referential_match: (print) => print.spaced(["matchKw", "typeKw"]),
Expand Down Expand Up @@ -81,7 +79,6 @@ export const constraintMap: CstToDocMap<AllConstraintNodes> = {
]),
]),
exclusion_param: (print) => print.spaced(["index", "withKw", "operator"]),
index_include_clause: (print) => print.spaced(["includeKw", "columns"]),
index_tablespace_clause: (print) =>
print.spaced(["usingIndexTablespaceKw", "name"]),
};
Expand Down
1 change: 0 additions & 1 deletion src/syntax/dialects/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const sqliteMap: CstToDocMap<AllSqliteNodes> = {
print.spaced(["detachKw", "databaseKw", "schema"]),
vacuum_stmt: (print) =>
print.spaced(["vacuumKw", "schema", "intoKw", "file"]),
reindex_stmt: (print) => print.spaced(["reindexKw", "table"]),
pragma_stmt: (print) => print.spaced(["pragmaKw", "pragma"]),
pragma_assignment: (print) => join(" = ", print(["name", "value"])),
pragma_func_call: (print) => print(["name", "args"]),
Expand Down
6 changes: 5 additions & 1 deletion src/syntax/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AllIndexNodes } from "sql-parser-cst";
import { group, join } from "../print_utils";
import { CstToDocMap } from "../CstToDocMap";

export const indexMap: CstToDocMap<AllIndexNodes> = {
export const indexMap: Partial<CstToDocMap<AllIndexNodes>> = {
create_index_stmt: (print) =>
group(
join(print.dynamicLine(), [
Expand All @@ -19,6 +19,9 @@ export const indexMap: CstToDocMap<AllIndexNodes> = {
...print("clauses"),
]),
),
index_specification: (print) =>
print.spaced(["expr", "opclass", "direction", "nullHandlingKw"]),
index_include_clause: (print) => print.spaced(["includeKw", "columns"]),
drop_index_stmt: (print) =>
print.spaced([
"dropKw",
Expand All @@ -30,4 +33,5 @@ export const indexMap: CstToDocMap<AllIndexNodes> = {
"table",
]),
verbose_all_columns: (print) => print.spaced("allColumnsKw"),
reindex_stmt: (print) => print.spaced(["reindexKw", "name"]),
};
2 changes: 1 addition & 1 deletion src/syntax/transformMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { mysqlMap } from "./dialects/mysql";
import { sqliteMap } from "./dialects/sqlite";
import { postgresqlMap } from "./dialects/postgresql";

export const transformMap: CstToDocMap<Node> = {
export const transformMap: Partial<CstToDocMap<Node>> = {
...aliasMap,
...alterActionMap,
...alterTableMap,
Expand Down
2 changes: 1 addition & 1 deletion src/syntax/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AllViewNodes } from "sql-parser-cst";
import { group, hardline, join, line } from "../print_utils";
import { CstToDocMap } from "../CstToDocMap";

export const viewMap: CstToDocMap<AllViewNodes> = {
export const viewMap: Partial<CstToDocMap<AllViewNodes>> = {
create_view_stmt: (print, node) => {
const hasOnlyAsClause = node.clauses.length === 1;
const hasManyClauses = node.clauses.length > 1;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2174,10 +2174,10 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==

sql-parser-cst@^0.26.0:
version "0.26.0"
resolved "https://registry.yarnpkg.com/sql-parser-cst/-/sql-parser-cst-0.26.0.tgz#8b439e24e56c57d7b8ab3ba00d858f48a5b0f181"
integrity sha512-ioMCDKo+4o2Z40wsar6Ughxxsaf1pYthZQLk9vlncSUBFQEeZz1bvqbGrUbWb/iFl0JECRyNHk92yPPLcYh5MA==
sql-parser-cst@^0.27.0:
version "0.27.0"
resolved "https://registry.yarnpkg.com/sql-parser-cst/-/sql-parser-cst-0.27.0.tgz#1785fc8939194aa526a159a1724b1f990e49a58f"
integrity sha512-220yHtTkweWRCCTPJJa3ViicxHuJPUELNVNYf9qT2hK7zbhRwUjOm1O3Tau+IQPXjY7MG/fuulVugTu5buW0bQ==

stack-utils@^2.0.3:
version "2.0.6"
Expand Down

0 comments on commit 65b9dcd

Please sign in to comment.