Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sql-parser-cst

Package Overview
Dependencies
Maintainers
0
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-parser-cst - npm Package Compare versions

Comparing version 0.28.1 to 0.29.0

lib/cst/Domain.d.ts

57

lib/cst/AlterAction.d.ts

@@ -7,6 +7,6 @@ import { BaseNode, Keyword } from "./Base";

import { NumberLiteral, StringLiteral } from "./Literal";
import { ConstraintModifier, TableConstraint } from "./Constraint";
import { ConstraintCollate, ConstraintModifier, TableConstraint } from "./Constraint";
import { Default } from "./Insert";
import { PostgresqlTableOption, SequenceOption, SequenceOptionList } from "./Node";
export type AllAlterActionNodes = AlterTableAction | AlterColumnAction | AlterSchemaAction | AlterViewAction | AlterIdentityAction | AlterIndexAction | ToggleItem | ReplicaIdentityUsingIndex | SetDataTypeCollateClause | SetDataTypeUsingClause | AlterActionAddConstraintConstraintName;
export type AllAlterActionNodes = AlterTableAction | AlterColumnAction | AlterSchemaAction | AlterViewAction | AlterIdentityAction | AlterIndexAction | AlterFunctionAction | AlterTypeAction | AlterDomainAction | ToggleItem | ReplicaIdentityUsingIndex | SetDataTypeCollateClause | SetDataTypeUsingClause | AlterActionAddConstraintConstraintName | AlterActionAddEnumValuePosition;
export type AlterTableAction = AlterActionRename | AlterActionRenameColumn | AlterActionAddColumn | AlterActionDropColumn | AlterActionAlterColumn | AlterActionSetDefaultCollate | AlterActionSetBigqueryOptions | AlterActionSetPostgresqlOptions | AlterActionResetPostgresqlOptions | AlterActionAddConstraint | AlterActionDropConstraint | AlterActionAlterConstraint | AlterActionRenameConstraint | AlterActionValidateConstraint | AlterActionDropPrimaryKey | AlterActionOwnerTo | AlterActionSetSchema | AlterActionEnable | AlterActionDisable | AlterActionForce | AlterActionNoForce | AlterActionSetTablespace | AlterActionSetAccessMethod | AlterActionClusterOn | AlterActionSetWithoutCluster | AlterActionSetWithoutOids | AlterActionSetLogged | AlterActionSetUnlogged | AlterActionInherit | AlterActionNoInherit | AlterActionOfType | AlterActionNotOfType | AlterActionReplicaIdentity;

@@ -18,2 +18,4 @@ export type AlterSchemaAction = AlterActionSetDefaultCollate | AlterActionSetBigqueryOptions | AlterActionRename | AlterActionOwnerTo;

export type AlterFunctionAction = AlterActionRename | AlterActionOwnerTo | AlterActionSetSchema | AlterActionDependsOnExtension | AlterActionNoDependsOnExtension;
export type AlterTypeAction = AlterActionRename | AlterActionOwnerTo | AlterActionSetSchema | AlterActionAddEnumValue | AlterActionRenameEnumValue | AlterActionRenameAttribute | AlterActionAddAttribute | AlterActionDropAttribute | AlterActionAlterAttribute;
export type AlterDomainAction = AlterActionRename | AlterActionOwnerTo | AlterActionSetSchema | AlterActionSetDefault | AlterActionDropDefault | AlterActionSetNotNull | AlterActionDropNotNull | AlterActionRenameConstraint | AlterActionValidateConstraint | AlterActionDropConstraint | AlterActionAddConstraint;
export interface AlterActionRename extends BaseNode {

@@ -235,2 +237,53 @@ type: "alter_action_rename";

}
export interface AlterActionAddEnumValue extends BaseNode {
type: "alter_action_add_enum_value";
addValueKw: [Keyword<"ADD">, Keyword<"VALUE">];
ifNotExistsKw?: [Keyword<"IF">, Keyword<"NOT">, Keyword<"EXISTS">];
value: StringLiteral;
position?: AlterActionAddEnumValuePosition;
}
export interface AlterActionAddEnumValuePosition extends BaseNode {
type: "alter_action_add_enum_value_position";
positionKw: Keyword<"BEFORE" | "AFTER">;
value: StringLiteral;
}
export interface AlterActionRenameEnumValue extends BaseNode {
type: "alter_action_rename_enum_value";
renameValueKw: [Keyword<"RENAME">, Keyword<"VALUE">];
oldValue: StringLiteral;
toKw: Keyword<"TO">;
newValue: StringLiteral;
}
export interface AlterActionRenameAttribute extends BaseNode {
type: "alter_action_rename_attribute";
renameAttributeKw: [Keyword<"RENAME">, Keyword<"ATTRIBUTE">];
oldName: Identifier;
toKw: Keyword<"TO">;
newName: Identifier;
behaviorKw?: Keyword<"CASCADE" | "RESTRICT">;
}
export interface AlterActionAddAttribute extends BaseNode {
type: "alter_action_add_attribute";
addAttributeKw: [Keyword<"ADD">, Keyword<"ATTRIBUTE">];
name: Identifier;
dataType: DataType;
constraint?: ConstraintCollate;
behaviorKw?: Keyword<"CASCADE" | "RESTRICT">;
}
export interface AlterActionDropAttribute extends BaseNode {
type: "alter_action_drop_attribute";
dropAttributeKw: [Keyword<"DROP">, Keyword<"ATTRIBUTE">];
ifExistsKw?: [Keyword<"IF">, Keyword<"EXISTS">];
name: Identifier;
behaviorKw?: Keyword<"CASCADE" | "RESTRICT">;
}
export interface AlterActionAlterAttribute extends BaseNode {
type: "alter_action_alter_attribute";
alterAttributeKw: [Keyword<"ALTER">, Keyword<"ATTRIBUTE">];
name: Identifier;
setDataTypeKw: [Keyword<"SET">, Keyword<"DATA">, Keyword<"TYPE">] | Keyword<"TYPE">;
dataType: DataType;
constraint?: ConstraintCollate;
behaviorKw?: Keyword<"CASCADE" | "RESTRICT">;
}
export type AlterColumnAction = AlterActionSetDefault | AlterActionDropDefault | AlterActionSetNotNull | AlterActionDropNotNull | AlterActionSetDataType | AlterActionSetBigqueryOptions | AlterActionSetPostgresqlOptions | AlterActionResetPostgresqlOptions | AlterActionSetVisible | AlterActionSetInvisible | AlterActionSetCompression | AlterActionSetStorage | AlterActionSetStatistics | AlterActionDropExpression | AlterActionDropIdentity | AlterActionAddIdentity | AlterActionAlterIdentity;

@@ -237,0 +290,0 @@ export interface AlterActionSetDefault extends BaseNode {

@@ -29,2 +29,3 @@ import { BaseNode, Keyword } from "./Base";

export type ColumnConstraint = ConstraintNull | ConstraintNotNull | ConstraintDefault | ConstraintAutoIncrement | ConstraintUnique | ConstraintPrimaryKey | ReferencesSpecification | ConstraintComment | ConstraintCheck | ConstraintIndex | ConstraintGenerated | ConstraintCollate | ConstraintVisible | ConstraintColumnFormat | ConstraintStorage | ConstraintEngineAttribute | ConstraintCompression | BigqueryOptions | PostgresqlOptions;
export type DomainConstraint = ConstraintCollate | ConstraintDefault | ConstraintNull | ConstraintNotNull | ConstraintCheck;
export interface ConstraintPrimaryKey extends BaseNode {

@@ -31,0 +32,0 @@ type: "constraint_primary_key";

2

lib/cst/DataType.d.ts

@@ -10,3 +10,3 @@ import { BaseNode, Empty, Keyword } from "./Base";

type: "named_data_type";
nameKw: Keyword | Keyword[];
name: Keyword | Keyword[] | Identifier;
params?: ParenExpr<ListExpr<Literal>> | GenericTypeParams;

@@ -13,0 +13,0 @@ }

@@ -115,4 +115,5 @@ import { AllColumns, BaseNode, Empty, Keyword } from "./Base";

type: "cast_operator_expr";
expr: Expr;
dataType: DataType;
left: Expr;
operator: "::";
right: DataType;
}

@@ -119,0 +120,0 @@ export interface CastArg extends BaseNode {

@@ -24,3 +24,2 @@ import { BaseNode, Keyword } from "./Base";

clauses: CreateFunctionClause[];
behaviorKw?: Keyword<"RESTRICT">;
}

@@ -115,3 +114,2 @@ export interface FunctionParam extends BaseNode {

resetAllKw: [Keyword<"RESET">, Keyword<"ALL">];
name: Identifier;
}

@@ -118,0 +116,0 @@ export interface DropFunctionStmt extends BaseNode {

@@ -49,2 +49,3 @@ export * from "./Alias";

import { AllDeleteNodes } from "./Delete";
import { AllDomainNodes } from "./Domain";
import { AllExprNodes } from "./Expr";

@@ -69,2 +70,3 @@ import { AllFrameNodes } from "./WindowFrame";

import { AllTriggerNodes } from "./Trigger";
import { AllTypeNodes } from "./Type";
import { AllUpdateNodes } from "./Update";

@@ -74,2 +76,2 @@ import { AllViewNodes } from "./View";

import { Statement } from "./Statement";
export type Node = Alias | AllAlterActionNodes | AllAlterTableNodes | AllBigqueryNodes | AllColumns | AllConstraintNodes | AllCreateTableNodes | AllDataTypeNodes | AllDeleteNodes | AllExprNodes | AllFrameNodes | AllFunctionNodes | AllIndexNodes | AllInsertNodes | AllMergeNodes | AllMysqlNodes | AllOtherClauses | AllPostgresqlNodes | AllPreparedStatementNodes | AllProcClauseNodes | AllProceduralNodes | AllProcedureNodes | AllRenameTableNodes | AllSelectNodes | AllSequenceNodes | AllSqliteNodes | AllTransactionNodes | AllTriggerNodes | AllUpdateNodes | AllViewNodes | Keyword | Program | Statement;
export type Node = Alias | AllAlterActionNodes | AllAlterTableNodes | AllBigqueryNodes | AllColumns | AllConstraintNodes | AllCreateTableNodes | AllDataTypeNodes | AllDeleteNodes | AllDomainNodes | AllExprNodes | AllFrameNodes | AllFunctionNodes | AllIndexNodes | AllInsertNodes | AllMergeNodes | AllMysqlNodes | AllOtherClauses | AllPostgresqlNodes | AllPreparedStatementNodes | AllProcClauseNodes | AllProceduralNodes | AllProcedureNodes | AllRenameTableNodes | AllSelectNodes | AllSequenceNodes | AllSqliteNodes | AllTransactionNodes | AllTriggerNodes | AllTypeNodes | AllUpdateNodes | AllViewNodes | Keyword | Program | Statement;

@@ -13,2 +13,3 @@ import { AllAlterTableStatements } from "./AlterTable";

import { AllTriggerStatements } from "./Trigger";
import { AllTypeStatements } from "./Type";
import { AllViewStatements } from "./View";

@@ -27,2 +28,2 @@ import { AnalyzeStmt } from "./Analyze";

import { AllPreparedStatements } from "./PreparedStatements";
export type Statement = AllAlterTableStatements | AllBigqueryStatements | AllDclStatements | AllFunctionStatements | AllIndexStatements | AllPreparedStatements | AllProceduralStatements | AllProcedureStatements | AllSchemaStatements | AllSequenceStatements | AllSqliteStatements | AllTransactionStatements | AllTriggerStatements | AllViewStatements | AnalyzeStmt | CompoundSelectStmt | CreateTableStmt | DeleteStmt | DropTableStmt | Empty | ExplainStmt | InsertStmt | MergeStmt | SelectStmt | TruncateStmt | UpdateStmt;
export type Statement = AllAlterTableStatements | AllBigqueryStatements | AllDclStatements | AllFunctionStatements | AllIndexStatements | AllPreparedStatements | AllProceduralStatements | AllProcedureStatements | AllSchemaStatements | AllSequenceStatements | AllSqliteStatements | AllTransactionStatements | AllTriggerStatements | AllTypeStatements | AllViewStatements | AnalyzeStmt | CompoundSelectStmt | CreateTableStmt | DeleteStmt | DropTableStmt | Empty | ExplainStmt | InsertStmt | MergeStmt | SelectStmt | TruncateStmt | UpdateStmt;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sqliteKeywords = void 0;
// All keywords listed in:
// SQLite keywords are listed in:
// https://www.sqlite.org/lang_keywords.html
//
// However, not all of them are fully reserved.
// I've marked the ones that by my testing are reserved with (R).
// This might or might not be fully accurate.
//
// Some keywords are never reserved. I've removed these from the list:
// - KEY
// Some are reserved only in certain contexts. I've removed these from the list:
// - COLUMN
//
exports.sqliteKeywords = {

@@ -29,3 +39,2 @@ ABORT: true,

COLLATE: true,
COLUMN: true,
COMMIT: true,

@@ -87,3 +96,2 @@ CONFLICT: true,

JOIN: true,
KEY: true,
LAST: true,

@@ -90,0 +98,0 @@ LEFT: true,

@@ -52,2 +52,28 @@ "use strict";

alter_action_replica_identity: (node) => (0, show_1.show)([node.replicaIdentityKw, node.identity]),
alter_action_add_enum_value: (node) => (0, show_1.show)([node.addValueKw, node.ifNotExistsKw, node.value, node.position]),
alter_action_add_enum_value_position: (node) => (0, show_1.show)([node.positionKw, node.value]),
alter_action_rename_enum_value: (node) => (0, show_1.show)([node.renameValueKw, node.oldValue, node.toKw, node.newValue]),
alter_action_rename_attribute: (node) => (0, show_1.show)([
node.renameAttributeKw,
node.oldName,
node.toKw,
node.newName,
node.behaviorKw,
]),
alter_action_add_attribute: (node) => (0, show_1.show)([
node.addAttributeKw,
node.name,
node.dataType,
node.constraint,
node.behaviorKw,
]),
alter_action_drop_attribute: (node) => (0, show_1.show)([node.dropAttributeKw, node.ifExistsKw, node.name, node.behaviorKw]),
alter_action_alter_attribute: (node) => (0, show_1.show)([
node.alterAttributeKw,
node.name,
node.setDataTypeKw,
node.dataType,
node.constraint,
node.behaviorKw,
]),
// ALTER COLUMN ...

@@ -54,0 +80,0 @@ alter_action_alter_column: (node) => (0, show_1.show)([node.alterKw, node.ifExistsKw, node.column, node.action]),

@@ -6,3 +6,3 @@ "use strict";

exports.dataTypeMap = {
named_data_type: (node) => (0, show_1.show)([node.nameKw, node.params]),
named_data_type: (node) => (0, show_1.show)([node.name, node.params]),
array_data_type: (node) => (0, show_1.show)([node.dataType, node.bounds]),

@@ -9,0 +9,0 @@ array_bounds: (node) => (0, show_1.show)(["[", node.bounds, "]"]),

@@ -22,3 +22,3 @@ "use strict";

cast_expr: (node) => (0, show_1.show)([node.castKw, node.args]),
cast_operator_expr: (node) => (0, show_1.show)([node.expr, "::", node.dataType]),
cast_operator_expr: (node) => (0, show_1.show)([node.left, node.operator, node.right]),
cast_arg: (node) => (0, show_1.show)([node.expr, node.asKw, node.dataType, node.format]),

@@ -25,0 +25,0 @@ cast_format: (node) => (0, show_1.show)([node.formatKw, node.string, node.timezone]),

@@ -13,2 +13,3 @@ "use strict";

const delete_1 = require("./delete");
const domain_1 = require("./domain");
const drop_table_1 = require("./drop_table");

@@ -28,2 +29,3 @@ const explain_1 = require("./explain");

const sequence_1 = require("./sequence");
const type_1 = require("./type");
const transaction_1 = require("./transaction");

@@ -41,2 +43,2 @@ const trigger_1 = require("./trigger");

const mysql_1 = require("./dialects/mysql");
exports.transformMap = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base_1.baseMap), select_1.selectMap), window_frame_1.frameMap), insert_1.insertMap), update_1.updateMap), delete_1.deleteMap), truncate_1.truncateMap), merge_1.mergeMap), create_table_1.createTableMap), constraint_1.constraintMap), alter_table_1.alterTableMap), alter_action_1.alterActionMap), drop_table_1.dropTableMap), rename_table_1.renameTableMap), schema_1.schemaMap), view_1.viewMap), index_1.indexMap), trigger_1.triggerMap), sequence_1.sequenceMap), function_1.functionMap), procedure_1.procedureMap), proc_clause_1.procClauseMap), analyze_1.analyzeMap), explain_1.explainMap), transaction_1.transactionMap), dcl_1.dclMap), procedural_language_1.proceduralLanguageMap), prepared_statements_1.preparedStatementsMap), other_clauses_1.otherClausesMap), sqlite_1.sqliteMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), expr_1.exprMap), data_type_1.dataTypeMap);
exports.transformMap = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base_1.baseMap), select_1.selectMap), window_frame_1.frameMap), insert_1.insertMap), update_1.updateMap), delete_1.deleteMap), truncate_1.truncateMap), merge_1.mergeMap), create_table_1.createTableMap), constraint_1.constraintMap), alter_table_1.alterTableMap), alter_action_1.alterActionMap), drop_table_1.dropTableMap), rename_table_1.renameTableMap), schema_1.schemaMap), view_1.viewMap), index_1.indexMap), trigger_1.triggerMap), sequence_1.sequenceMap), type_1.typeMap), domain_1.domainMap), function_1.functionMap), procedure_1.procedureMap), proc_clause_1.procClauseMap), analyze_1.analyzeMap), explain_1.explainMap), transaction_1.transactionMap), dcl_1.dclMap), procedural_language_1.proceduralLanguageMap), prepared_statements_1.preparedStatementsMap), other_clauses_1.otherClausesMap), sqlite_1.sqliteMap), bigquery_1.bigqueryMap), mysql_1.mysqlMap), postgresql_1.postgresqlMap), expr_1.exprMap), data_type_1.dataTypeMap);

@@ -1,2 +0,2 @@

import { Alias, BinaryExpr, CompoundSelectStmt, Expr, ListExpr, Identifier, JoinExpr, Keyword, Node, ParenExpr, PostfixOpExpr, PrefixOpExpr, SubSelect, Whitespace, MemberExpr, PivotExpr, UnpivotExpr, TablesampleExpr, FuncCall, ForSystemTimeAsOfExpr, ArrayDataType } from "../cst/Node";
import { Alias, BinaryExpr, CompoundSelectStmt, Expr, ListExpr, Identifier, JoinExpr, Keyword, Node, ParenExpr, PostfixOpExpr, PrefixOpExpr, SubSelect, Whitespace, MemberExpr, PivotExpr, UnpivotExpr, TablesampleExpr, FuncCall, ForSystemTimeAsOfExpr, ArrayDataType, DataType } from "../cst/Node";
export declare function createStringConcatExprChain(head: BinaryExpr["left"], tail: [Whitespace[], BinaryExpr["right"]][]): Expr;

@@ -10,2 +10,3 @@ export declare function createBinaryExprChain(head: BinaryExpr["left"], tail: [

export declare function createBinaryExpr(left: BinaryExpr["left"], c1: Whitespace[], op: BinaryExpr["operator"], c2: Whitespace[], right: BinaryExpr["right"]): BinaryExpr;
export declare function createCastOperatorExprChain(head: Expr, tail: [Whitespace[], "::", Whitespace[], DataType][]): Expr;
export declare function createCompoundSelectStmtChain(head: CompoundSelectStmt["left"], tail: [

@@ -12,0 +13,0 @@ Whitespace[],

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createArrayDataTypeChain = exports.createListExpr = exports.createParenExpr = exports.createAlias = exports.createIdentifier = exports.createKeyword = exports.createPostfixOpExpr = exports.createPrefixOpExpr = exports.createFuncCall = exports.createMemberExprChain = exports.createJoinExprChain = exports.createCompoundSelectStmt = exports.createCompoundSelectStmtChain = exports.createBinaryExpr = exports.createBinaryExprChain = exports.createStringConcatExprChain = void 0;
exports.createArrayDataTypeChain = exports.createListExpr = exports.createParenExpr = exports.createAlias = exports.createIdentifier = exports.createKeyword = exports.createPostfixOpExpr = exports.createPrefixOpExpr = exports.createFuncCall = exports.createMemberExprChain = exports.createJoinExprChain = exports.createCompoundSelectStmt = exports.createCompoundSelectStmtChain = exports.createCastOperatorExprChain = exports.createBinaryExpr = exports.createBinaryExprChain = exports.createStringConcatExprChain = void 0;
const whitespace_1 = require("./whitespace");

@@ -35,2 +35,14 @@ const list_1 = require("./list");

exports.createBinaryExpr = createBinaryExpr;
function createCastOperatorExprChain(head, tail) {
return tail.reduce((left, [c1, op, c2, right]) => deriveLoc(createCastExpr(left, c1, op, c2, right)), head);
}
exports.createCastOperatorExprChain = createCastOperatorExprChain;
function createCastExpr(left, c1, op, c2, right) {
return {
type: "cast_operator_expr",
left: (0, whitespace_1.trailing)(left, c1),
operator: op,
right: (0, whitespace_1.leading)(right, c2),
};
}
function createCompoundSelectStmtChain(head, tail) {

@@ -37,0 +49,0 @@ return tail.reduce((left, [c1, op, c2, right]) => deriveLoc(createCompoundSelectStmt(left, c1, op, c2, right)), head);

@@ -5,3 +5,3 @@ {

"license": "GPL-2.0-or-later",
"version": "0.28.1",
"version": "0.29.0",
"main": "lib/main.js",

@@ -50,2 +50,3 @@ "types": "lib/main.d.ts",

"@types/jest": "^29.1.2",
"@types/node": "^22.7.9",
"@typescript-eslint/eslint-plugin": "^5.47.0",

@@ -52,0 +53,0 @@ "@typescript-eslint/parser": "^5.47.0",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc