sql-parser-cst
Advanced tools
Comparing version 0.27.1 to 0.28.0
@@ -16,2 +16,3 @@ import { BaseNode, Keyword } from "./Base"; | ||
export type AlterIndexAction = AlterActionRename | AlterActionSetTablespace | AlterActionDependsOnExtension | AlterActionNoDependsOnExtension | AlterActionSetPostgresqlOptions | AlterActionResetPostgresqlOptions | AlterActionAlterColumn | AlterActionAttachPartition; | ||
export type AlterFunctionAction = AlterActionRename | AlterActionOwnerTo | AlterActionSetSchema | AlterActionDependsOnExtension | AlterActionNoDependsOnExtension; | ||
export interface AlterActionRename extends BaseNode { | ||
@@ -47,3 +48,3 @@ type: "alter_action_rename"; | ||
ifExistsKw?: [Keyword<"IF">, Keyword<"EXISTS">]; | ||
column: Identifier; | ||
column: Identifier | NumberLiteral; | ||
action: AlterColumnAction; | ||
@@ -50,0 +51,0 @@ } |
@@ -29,3 +29,3 @@ import { BaseNode, Keyword } from "./Base"; | ||
type: "relation_kind"; | ||
kindKw: Keyword<"TEMP" | "TEMPORARY"> | [Keyword<"GLOBAL" | "LOCAL">, Keyword<"TEMPORARY" | "TEMP">] | Keyword<"UNLOGGED"> | Keyword<"FOREIGN"> | Keyword<"EXTERNAL"> | Keyword<"SNAPSHOT"> | Keyword<"VIRTUAL"> | Keyword<"MATERIALIZED"> | Keyword<"RECURSIVE">; | ||
kindKw: Keyword<"TEMP" | "TEMPORARY"> | [Keyword<"GLOBAL" | "LOCAL">, Keyword<"TEMPORARY" | "TEMP">] | Keyword<"UNLOGGED"> | Keyword<"FOREIGN"> | Keyword<"EXTERNAL"> | Keyword<"SNAPSHOT"> | Keyword<"VIRTUAL"> | Keyword<"MATERIALIZED"> | Keyword<"RECURSIVE"> | Keyword<"CONSTRAINT">; | ||
} | ||
@@ -32,0 +32,0 @@ export interface ColumnDefinition extends BaseNode { |
import { AllColumns, BaseNode, Empty, Keyword } from "./Base"; | ||
import { DataType } from "./DataType"; | ||
import { Literal, StringLiteral } from "./Literal"; | ||
import { Node, Program } from "./Node"; | ||
import { Node, Program, TriggerEventExpr } from "./Node"; | ||
import { LimitClause, OrderByClause, SubSelect, WhereClause, WindowDefinition } from "./Select"; | ||
@@ -9,3 +9,3 @@ import { Default } from "./Insert"; | ||
export type AllExprNodes = Expr | FuncArgs | NamedArg | CastArg | CastFormat | CastFormatTimezone | RaiseExprType | ExtractFrom | FilterArg | OverArg | HavingArg | CaseWhen<Expr | Program> | CaseElse<Expr | Program> | IntervalUnitRange | IntervalUnit | WeekExpr | FullTextMatchArgs | ArraySubscript | ArraySubscriptSpecifier | ArraySliceSpecifier; | ||
export type Expr = ListExpr | ParenExpr | BinaryExpr | PrefixOpExpr | PostfixOpExpr | FuncCall | CastExpr | CastOperatorExpr | RaiseExpr | ExtractExpr | BetweenExpr | CaseExpr | RowConstructor | IntervalExpr | StringWithCharset | QuantifierExpr | FullTextMatchExpr | Literal | MemberExpr | BigQueryQuotedMemberExpr | Identifier | Variable | Parameter | TypedExpr | ArrayExpr | StructExpr; | ||
export type Expr = ListExpr | ParenExpr | BinaryExpr | BinaryExpr<TriggerEventExpr, Keyword<"OR">, TriggerEventExpr> | PrefixOpExpr | PostfixOpExpr | FuncCall | CastExpr | CastOperatorExpr | RaiseExpr | ExtractExpr | BetweenExpr | CaseExpr | RowConstructor | ArrayConstructor | IntervalExpr | StringWithCharset | QuantifierExpr | FullTextMatchExpr | Literal | MemberExpr | BigQueryQuotedMemberExpr | Identifier | Variable | Parameter | TypedExpr | ArrayExpr | StructExpr; | ||
export interface ListExpr<T = Node> extends BaseNode { | ||
@@ -42,2 +42,3 @@ type: "list_expr"; | ||
* "" (empty string - in MySQL adjecent strings get concatenated) | ||
* "\n" (in PostgreSQL newline-separated strings strings get concatenated) | ||
* logic: | ||
@@ -59,3 +60,3 @@ * && (MySQL AND) | ||
type SymbolOperator = string; | ||
type KeywordOperator = Keyword<"DIV"> | Keyword<"MOD"> | Keyword<"AND"> | Keyword<"OR"> | Keyword<"XOR"> | Keyword<"COLLATE"> | Keyword<"IS"> | [Keyword<"IS">, Keyword<"NOT">] | [Keyword<"IS">, Keyword<"DISTINCT">, Keyword<"FROM">] | [Keyword<"IS">, Keyword<"NOT">, Keyword<"DISTINCT">, Keyword<"FROM">] | Keyword<"IN"> | [Keyword<"NOT">, Keyword<"IN">] | Keyword<"LIKE" | "RLIKE" | "ILIKE" | "GLOB" | "MATCH"> | [Keyword<"NOT">, Keyword<"LIKE" | "RLIKE" | "ILIKE" | "GLOB" | "MATCH">] | [Keyword<"SIMILAR">, Keyword<"TO">] | [Keyword<"NOT">, Keyword<"SIMILAR">, Keyword<"TO">] | [Keyword<"MEMBER">, Keyword<"OF">] | [Keyword<"SOUNDS">, Keyword<"LIKE">] | Keyword<"ESCAPE"> | [Keyword<"AT">, Keyword<"TIME">, Keyword<"ZONE">]; | ||
type KeywordOperator = Keyword<"DIV"> | Keyword<"MOD"> | Keyword<"AND"> | Keyword<"OR"> | Keyword<"XOR"> | Keyword<"COLLATE"> | Keyword<"IS"> | [Keyword<"IS">, Keyword<"NOT">] | [Keyword<"IS">, Keyword<"DISTINCT">, Keyword<"FROM">] | [Keyword<"IS">, Keyword<"NOT">, Keyword<"DISTINCT">, Keyword<"FROM">] | Keyword<"IN"> | [Keyword<"NOT">, Keyword<"IN">] | Keyword<"LIKE" | "RLIKE" | "ILIKE" | "GLOB" | "MATCH"> | [Keyword<"NOT">, Keyword<"LIKE" | "RLIKE" | "ILIKE" | "GLOB" | "MATCH">] | [Keyword<"SIMILAR">, Keyword<"TO">] | [Keyword<"NOT">, Keyword<"SIMILAR">, Keyword<"TO">] | [Keyword<"MEMBER">, Keyword<"OF">] | [Keyword<"SOUNDS">, Keyword<"LIKE">] | Keyword<"ESCAPE"> | Keyword<"UESCAPE"> | [Keyword<"AT">, Keyword<"TIME">, Keyword<"ZONE">]; | ||
export interface PrefixOpExpr extends BaseNode { | ||
@@ -195,2 +196,7 @@ type: "prefix_op_expr"; | ||
} | ||
export interface ArrayConstructor extends BaseNode { | ||
type: "array_constructor"; | ||
arrayKw: Keyword<"ARRAY">; | ||
expr: ParenExpr<SubSelect>; | ||
} | ||
export interface IntervalExpr extends BaseNode { | ||
@@ -197,0 +203,0 @@ type: "interval_expr"; |
@@ -10,4 +10,5 @@ import { BaseNode, Keyword } from "./Base"; | ||
import { Default } from "./Insert"; | ||
export type AllFunctionNodes = AllFunctionStatements | FunctionParam | FunctionParamDefault | ReturnClause | DynamicallyLoadedFunction | FunctionWindowClause | FunctionBehaviorClause | FunctionSecurityClause | FunctionCostClause | FunctionRowsClause | FunctionSupportClause | FunctionTransformClause | TransformType | SetParameterClause | SetParameterFromCurrentClause; | ||
export type AllFunctionStatements = CreateFunctionStmt | DropFunctionStmt; | ||
import { AlterFunctionAction } from "./AlterAction"; | ||
export type AllFunctionNodes = AllFunctionStatements | FunctionParam | FunctionParamDefault | ReturnClause | DynamicallyLoadedFunction | FunctionWindowClause | FunctionBehaviorClause | FunctionSecurityClause | FunctionCostClause | FunctionRowsClause | FunctionSupportClause | FunctionTransformClause | TransformType | SetParameterClause | SetParameterFromCurrentClause | ResetParameterClause | ResetAllParametersClause; | ||
export type AllFunctionStatements = CreateFunctionStmt | DropFunctionStmt | AlterFunctionStmt; | ||
export interface CreateFunctionStmt extends BaseNode { | ||
@@ -24,2 +25,3 @@ type: "create_function_stmt"; | ||
clauses: CreateFunctionClause[]; | ||
behaviorKw?: Keyword<"RESTRICT">; | ||
} | ||
@@ -106,2 +108,12 @@ export interface FunctionParam extends BaseNode { | ||
} | ||
export interface ResetParameterClause extends BaseNode { | ||
type: "reset_parameter_clause"; | ||
resetKw: Keyword<"RESET">; | ||
name: Identifier; | ||
} | ||
export interface ResetAllParametersClause extends BaseNode { | ||
type: "reset_all_parameters_clause"; | ||
resetAllKw: [Keyword<"RESET">, Keyword<"ALL">]; | ||
name: Identifier; | ||
} | ||
export interface DropFunctionStmt extends BaseNode { | ||
@@ -117,2 +129,12 @@ type: "drop_function_stmt"; | ||
} | ||
export interface AlterFunctionStmt extends BaseNode { | ||
type: "alter_function_stmt"; | ||
alterKw: Keyword<"ALTER">; | ||
functionKw: Keyword<"FUNCTION">; | ||
name: EntityName; | ||
params?: ParenExpr<ListExpr<FunctionParam>>; | ||
actions: (AlterFunctionAction | AlterFunctionClause)[]; | ||
behaviorKw?: Keyword<"RESTRICT">; | ||
} | ||
type AlterFunctionClause = SetParameterClause | SetParameterFromCurrentClause | ResetParameterClause | ResetAllParametersClause | FunctionBehaviorClause | FunctionSecurityClause | FunctionCostClause | FunctionRowsClause | FunctionSupportClause; | ||
export {}; |
@@ -7,5 +7,6 @@ import { BaseNode, Keyword } from "./Base"; | ||
import { BlockStmt } from "./ProceduralLanguage"; | ||
import { DynamicallyLoadedFunction, FunctionParam, FunctionSecurityClause, FunctionTransformClause, SetParameterClause, SetParameterFromCurrentClause } from "./Function"; | ||
import { DynamicallyLoadedFunction, FunctionParam, FunctionSecurityClause, FunctionTransformClause, ResetAllParametersClause, ResetParameterClause, SetParameterClause, SetParameterFromCurrentClause } from "./Function"; | ||
import { AlterFunctionAction } from "./AlterAction"; | ||
export type AllProcedureNodes = AllProcedureStatements; | ||
export type AllProcedureStatements = CreateProcedureStmt | DropProcedureStmt; | ||
export type AllProcedureStatements = CreateProcedureStmt | DropProcedureStmt | AlterProcedureStmt; | ||
export interface CreateProcedureStmt extends BaseNode { | ||
@@ -31,2 +32,12 @@ type: "create_procedure_stmt"; | ||
} | ||
export interface AlterProcedureStmt extends BaseNode { | ||
type: "alter_procedure_stmt"; | ||
alterKw: Keyword<"ALTER">; | ||
procedureKw: Keyword<"PROCEDURE">; | ||
name: EntityName; | ||
params?: ParenExpr<ListExpr<FunctionParam>>; | ||
actions: (AlterFunctionAction | AlterProcedureClause)[]; | ||
behaviorKw?: Keyword<"RESTRICT">; | ||
} | ||
type AlterProcedureClause = SetParameterClause | SetParameterFromCurrentClause | ResetParameterClause | ResetAllParametersClause | FunctionSecurityClause; | ||
export {}; |
import { BaseNode, Keyword } from "./Base"; | ||
import { Expr, Identifier, ListExpr, EntityName } from "./Expr"; | ||
import { RelationKind } from "./CreateTable"; | ||
import { Expr, Identifier, ListExpr, EntityName, ParenExpr, BinaryExpr } from "./Expr"; | ||
import { BlockStmt } from "./ProceduralLanguage"; | ||
export type AllTriggerNodes = AllTriggerStatements | TriggerEvent | TriggerCondition; | ||
export type AllTriggerNodes = AllTriggerStatements | TriggerEvent | TriggerTarget | ForEachClause | WhenClause | FromReferencedTableClause | TriggerTimingClause | TriggerReferencingClause | TriggerTransition | ExecuteClause; | ||
export type AllTriggerStatements = CreateTriggerStmt | DropTriggerStmt; | ||
@@ -9,25 +10,64 @@ export interface CreateTriggerStmt extends BaseNode { | ||
createKw: Keyword<"CREATE">; | ||
temporaryKw?: Keyword<"TEMP" | "TEMPORARY">; | ||
orReplaceKw?: [Keyword<"OR">, Keyword<"REPLACE">]; | ||
kind?: RelationKind; | ||
triggerKw: Keyword<"TRIGGER">; | ||
ifNotExistsKw?: [Keyword<"IF">, Keyword<"NOT">, Keyword<"EXISTS">]; | ||
name: EntityName; | ||
event: TriggerEvent; | ||
forEachRowKw?: [Keyword<"FOR">, Keyword<"EACH">, Keyword<"ROW">]; | ||
condition?: TriggerCondition; | ||
body: BlockStmt; | ||
timeKw?: Keyword<"BEFORE" | "AFTER"> | [Keyword<"INSTEAD">, Keyword<"OF">]; | ||
event: TriggerEventExpr; | ||
target: TriggerTarget; | ||
clauses: TriggerClause[]; | ||
body: BlockStmt | ExecuteClause; | ||
} | ||
export type TriggerEventExpr = BinaryExpr<TriggerEventExpr, Keyword<"OR">, TriggerEventExpr> | TriggerEvent; | ||
export interface TriggerEvent extends BaseNode { | ||
type: "trigger_event"; | ||
timeKw?: Keyword<"BEFORE" | "AFTER"> | [Keyword<"INSTEAD">, Keyword<"OF">]; | ||
eventKw: Keyword<"INSERT" | "DELETE" | "UPDATE">; | ||
eventKw: Keyword<"INSERT" | "DELETE" | "UPDATE" | "TRUNCATE">; | ||
ofKw?: Keyword<"OF">; | ||
columns?: ListExpr<Identifier>; | ||
} | ||
export interface TriggerTarget extends BaseNode { | ||
type: "trigger_target"; | ||
onKw: Keyword<"ON">; | ||
table: EntityName; | ||
} | ||
export interface TriggerCondition extends BaseNode { | ||
type: "trigger_condition"; | ||
type TriggerClause = ForEachClause | WhenClause | FromReferencedTableClause | TriggerTimingClause | TriggerReferencingClause; | ||
export interface ForEachClause extends BaseNode { | ||
type: "for_each_clause"; | ||
forEachKw: [Keyword<"FOR">, Keyword<"EACH">] | Keyword<"FOR">; | ||
itemKw: Keyword<"ROW" | "STATEMENT">; | ||
} | ||
export interface WhenClause extends BaseNode { | ||
type: "when_clause"; | ||
whenKw?: Keyword<"WHEN">; | ||
expr: Expr; | ||
} | ||
export interface FromReferencedTableClause extends BaseNode { | ||
type: "from_referenced_table_clause"; | ||
fromKw: Keyword<"FROM">; | ||
table: EntityName; | ||
} | ||
export interface TriggerTimingClause extends BaseNode { | ||
type: "trigger_timing_clause"; | ||
timingKw?: [Keyword<"NOT">, Keyword<"DEFERRABLE">] | Keyword<"DEFERRABLE"> | [Keyword<"INITIALLY">, Keyword<"DEFERRED">] | [Keyword<"INITIALLY">, Keyword<"IMMEDIATE">] | [Keyword<"DEFERRABLE">, Keyword<"INITIALLY">, Keyword<"DEFERRED">] | [Keyword<"DEFERRABLE">, Keyword<"INITIALLY">, Keyword<"IMMEDIATE">]; | ||
} | ||
export interface TriggerReferencingClause extends BaseNode { | ||
type: "trigger_referencing_clause"; | ||
referencingKw: Keyword<"REFERENCING">; | ||
transitions: ListExpr<TriggerTransition>; | ||
} | ||
export interface TriggerTransition extends BaseNode { | ||
type: "trigger_transition"; | ||
oldOrNewKw: Keyword<"OLD" | "NEW">; | ||
rowOrTableKw: Keyword<"TABLE" | "ROW">; | ||
asKw?: Keyword<"AS">; | ||
name: Identifier; | ||
} | ||
export interface ExecuteClause extends BaseNode { | ||
type: "execute_clause"; | ||
executeKw: Keyword<"EXECUTE">; | ||
functionKw: Keyword<"FUNCTION" | "PROCEDURE">; | ||
name: EntityName; | ||
args: ParenExpr<ListExpr<Expr>>; | ||
} | ||
export interface DropTriggerStmt extends BaseNode { | ||
@@ -39,1 +79,2 @@ type: "drop_trigger_stmt"; | ||
} | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.postgresqlKeywords = void 0; | ||
// https://www.postgresql.org/docs/14/sql-keywords-appendix.html | ||
// TODO: update for Postgres 16 | ||
// https://www.postgresql.org/docs/16/sql-keywords-appendix.html | ||
exports.postgresqlKeywords = { | ||
@@ -132,2 +131,3 @@ ALL: true, | ||
SYMMETRIC: true, | ||
SYSTEM_USER: true, | ||
TABLE: true, | ||
@@ -134,0 +134,0 @@ TABLESAMPLE: true, |
@@ -27,2 +27,3 @@ "use strict"; | ||
row_constructor: (node) => (0, show_1.show)([node.rowKw, node.row]), | ||
array_constructor: (node) => (0, show_1.show)([node.arrayKw, node.expr]), | ||
raise_expr: (node) => (0, show_1.show)([node.raiseKw, node.args]), | ||
@@ -29,0 +30,0 @@ raise_expr_type: (node) => (0, show_1.show)(node.typeKw), |
@@ -31,2 +31,4 @@ "use strict"; | ||
set_parameter_from_current_clause: (node) => (0, show_1.show)([node.setKw, node.name, node.fromCurrentKw]), | ||
reset_parameter_clause: (node) => (0, show_1.show)([node.resetKw, node.name]), | ||
reset_all_parameters_clause: (node) => (0, show_1.show)([node.resetAllKw]), | ||
drop_function_stmt: (node) => (0, show_1.show)([ | ||
@@ -41,2 +43,10 @@ node.dropKw, | ||
]), | ||
alter_function_stmt: (node) => (0, show_1.show)([ | ||
node.alterKw, | ||
node.functionKw, | ||
node.name, | ||
node.params, | ||
node.actions, | ||
node.behaviorKw, | ||
]), | ||
}; |
@@ -23,2 +23,10 @@ "use strict"; | ||
]), | ||
alter_procedure_stmt: (node) => (0, show_1.show)([ | ||
node.alterKw, | ||
node.procedureKw, | ||
node.name, | ||
node.params, | ||
node.actions, | ||
node.behaviorKw, | ||
]), | ||
}; |
@@ -8,22 +8,24 @@ "use strict"; | ||
node.createKw, | ||
node.temporaryKw, | ||
node.orReplaceKw, | ||
node.kind, | ||
node.triggerKw, | ||
node.ifNotExistsKw, | ||
node.name, | ||
node.timeKw, | ||
node.event, | ||
node.forEachRowKw, | ||
node.condition, | ||
node.target, | ||
node.clauses, | ||
node.body, | ||
]), | ||
trigger_event: (node) => (0, show_1.show)([ | ||
node.timeKw, | ||
node.eventKw, | ||
node.ofKw, | ||
node.columns, | ||
node.onKw, | ||
node.table, | ||
]), | ||
trigger_condition: (node) => (0, show_1.show)([node.whenKw, node.expr]), | ||
trigger_event: (node) => (0, show_1.show)([node.eventKw, node.ofKw, node.columns]), | ||
trigger_target: (node) => (0, show_1.show)([node.onKw, node.table]), | ||
for_each_clause: (node) => (0, show_1.show)([node.forEachKw, node.itemKw]), | ||
when_clause: (node) => (0, show_1.show)([node.whenKw, node.expr]), | ||
from_referenced_table_clause: (node) => (0, show_1.show)([node.fromKw, node.table]), | ||
trigger_timing_clause: (node) => (0, show_1.show)([node.timingKw]), | ||
trigger_referencing_clause: (node) => (0, show_1.show)([node.referencingKw, node.transitions]), | ||
trigger_transition: (node) => (0, show_1.show)([node.oldOrNewKw, node.rowOrTableKw, node.asKw, node.name]), | ||
execute_clause: (node) => (0, show_1.show)([node.executeKw, node.functionKw, node.name, node.args]), | ||
// DROP TRIGGER | ||
drop_trigger_stmt: (node) => (0, show_1.show)([node.dropTriggerKw, node.ifExistsKw, node.trigger]), | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"license": "GPL-2.0-or-later", | ||
"version": "0.27.1", | ||
"version": "0.28.0", | ||
"main": "lib/main.js", | ||
@@ -45,3 +45,3 @@ "types": "lib/main.d.ts", | ||
"ts:check": "tsc --noEmit", | ||
"changelog": "auto-changelog -p" | ||
"changelog": "auto-changelog -p --starting-version $VERSION --ending-version $VERSION" | ||
}, | ||
@@ -70,4 +70,2 @@ "devDependencies": { | ||
"stdout": true, | ||
"startingVersion": "v0.25.0", | ||
"endingVersion": "v0.25.0", | ||
"breakingPattern": "BREAKING!", | ||
@@ -74,0 +72,0 @@ "commitLimit": false, |
@@ -335,2 +335,12 @@ # SQL Parser CST [![npm version](https://img.shields.io/npm/v/sql-parser-cst)](https://www.npmjs.com/package/sql-parser-cst) ![build status](https://github.com/nene/sql-parser-cst/actions/workflows/build.yml/badge.svg) | ||
### Release | ||
Generate new release with `yarn publish`. | ||
To generate a changelog use the `yarn changelog` command: | ||
``` | ||
VERSION=v0.27.0 yarn changelog` | ||
``` | ||
## Acknowledgements | ||
@@ -337,0 +347,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5522003
7598
357
203