New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sqltyper

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqltyper - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

2

dist/package.json
{
"name": "sqltyper",
"version": "1.3.1",
"version": "1.3.2",
"description": "Typed SQL queries in PostgreSQL",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -36,2 +36,6 @@ "use strict";

Expression.createTernaryOp = createTernaryOp;
function createAnySomeAll(lhs, op, comparison, subquery) {
return { kind: 'AnySomeAll', lhs, op, comparison, subquery };
}
Expression.createAnySomeAll = createAnySomeAll;
function createExistsOp(subquery) {

@@ -98,2 +102,4 @@ return { kind: 'ExistsOp', subquery };

return handlers.ternaryOp == null ? elseVal : handlers.ternaryOp(expr);
case 'AnySomeAll':
return handlers.anySomeAll == null ? elseVal : handlers.anySomeAll(expr);
case 'ExistsOp':

@@ -138,2 +144,4 @@ return handlers.existsOp == null ? elseVal : handlers.existsOp(expr);

return handlers.ternaryOp(expr);
case 'AnySomeAll':
return handlers.anySomeAll(expr);
case 'ExistsOp':

@@ -201,2 +209,6 @@ return handlers.existsOp(expr);

equals(a.rhs2, b.rhs2));
case 'AnySomeAll':
if (a.kind !== b.kind)
return false;
return false; // TODO
case 'ExistsOp':

@@ -411,4 +423,4 @@ if (a.kind !== b.kind)

(function (Delete) {
function create(table, as, where, returning) {
return { kind: 'Delete', table, as, where, returning };
function create(ctes, table, as, where, returning) {
return { kind: 'Delete', ctes, table, as, where, returning };
}

@@ -415,0 +427,0 @@ Delete.create = create;

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

'AND',
'ANY',
'ARRAY',

@@ -65,2 +66,3 @@ 'AS',

'SIMILAR',
'SOME',
'SYMMETRIC',

@@ -229,2 +231,3 @@ 'THEN',

func('bool', 'safe'),
func('daterange', 'neverNull'),
func('now', 'neverNull'),

@@ -231,0 +234,0 @@ func('count', 'neverNull'),

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

update: ({ ctes, table, as, from, where, returning }) => (0, function_1.pipe)(combineVirtualTables(outsideCTEs, getVirtualTablesForWithQueries(client, paramNullability, ctes)), InferM.chain((combinedCTEs) => combineSourceColumns(getSourceColumnsForTableExpr(client, combinedCTEs, paramNullability, from), getSourceColumnsForTable(client, combinedCTEs, table, as))), InferM.chain((sourceColumns) => inferSelectListOutput(client, outsideCTEs, sourceColumns, paramNullability, [where], returning))),
delete: ({ table, as, where, returning }) => (0, function_1.pipe)(getSourceColumnsForTable(client, outsideCTEs, table, as), InferM.chain((sourceColumns) => inferSelectListOutput(client, outsideCTEs, sourceColumns, paramNullability, [where], returning))),
delete: ({ ctes, table, as, where, returning }) => (0, function_1.pipe)(combineVirtualTables(outsideCTEs, getVirtualTablesForWithQueries(client, paramNullability, ctes)), InferM.chain((combinedCTEs) => getSourceColumnsForTable(client, combinedCTEs, table, as)), InferM.chain((sourceColumns) => inferSelectListOutput(client, outsideCTEs, sourceColumns, paramNullability, [where], returning))),
});

@@ -143,5 +143,5 @@ }

}
const anyTE = (0, function_1.flow)(field_nullability_1.FieldNullability.any, Warn.of, TaskEither.right);
const arrayTE = (0, function_1.flow)(field_nullability_1.FieldNullability.array, Warn.of, TaskEither.right);
function inferExpressionNullability(client, outsideCTEs, sourceColumns, paramNullability, nonNullExprs, expression) {
const anyTE = (0, function_1.flow)(field_nullability_1.FieldNullability.any, Warn.of, TaskEither.right);
const arrayTE = (0, function_1.flow)(field_nullability_1.FieldNullability.array, Warn.of, TaskEither.right);
if (nonNullExprs.some((nonNull) => ast.Expression.equals(expression, nonNull))) {

@@ -213,2 +213,6 @@ // This expression is guaranteed to be not NULL by a

},
anySomeAll: ({ lhs, subquery }) =>
// expr op ANY/SOME/ALL (subquery) returns NULL if expr is NULL, or if
// there's no match and any value produced by the subquery is NULL
(0, function_1.pipe)(InferM.right(field_nullability_1.FieldNullability.disjunction), InferM.ap(inferExpressionNullability(client, outsideCTEs, sourceColumns, paramNullability, nonNullExprs, lhs)), InferM.ap(inferScalarSubqueryNullability(client, outsideCTEs, paramNullability, subquery))),
// EXISTS (subquery) never returns NULL

@@ -247,7 +251,3 @@ existsOp: () => anyTE(false),

case 'InSubquery':
return (0, function_1.pipe)(getOutputColumns(client, outsideCTEs, paramNullability, rhs.subquery), InferM.chain((columns) => {
if (columns.length != 1)
return TaskEither.left('subquery must return only one column');
return anyTE(columns[0].nullability.nullable);
}));
return inferScalarSubqueryNullability(client, outsideCTEs, paramNullability, rhs.subquery);
}

@@ -257,18 +257,9 @@ })())),

// the inside depends on the inside select list expression
arraySubQuery: ({ subquery }) => (0, function_1.pipe)(getOutputColumns(client, outsideCTEs, paramNullability, subquery), InferM.chain((columns) => {
if (columns.length != 1)
return TaskEither.left('subquery must return only one column');
return arrayTE(
// An array constructed from a subquery is never NULL itself
false,
// Element nullability depends on the subquery column nullability
columns[0].nullability.nullable);
})),
arraySubQuery: ({ subquery }) => inferScalarSubqueryNullability(client, outsideCTEs, paramNullability, subquery,
// An array constructed from a subquery is never NULL itself
// Element nullability depends on the subquery column nullability
(nullability) => arrayTE(false, nullability)),
scalarSubQuery: ({ subquery }) =>
// (subquery) is nullable if the single output column of the subquery is nullable
(0, function_1.pipe)(getOutputColumns(client, outsideCTEs, paramNullability, subquery), InferM.chain((columns) => {
if (columns.length != 1)
return TaskEither.left('subquery must return only one column');
return anyTE(columns[0].nullability.nullable);
})),
inferScalarSubqueryNullability(client, outsideCTEs, paramNullability, subquery),
case: ({ branches, else_ }) => {

@@ -300,2 +291,16 @@ if (else_ === null) {

}
function inferScalarSubqueryNullability(client, outsideCTEs, paramNullability, subquery, fieldNullabilityConstructor = anyTE) {
return (0, function_1.pipe)(getOutputColumns(client, outsideCTEs, paramNullability, subquery), InferM.chain((columns) => {
if (columns.length != 1)
return TaskEither.left('a scalar subquery must return only one column');
return fieldNullabilityConstructor(columns[0].nullability.nullable);
}));
}
// Given a condition (a boolean expression), return a list of expressions that
// are certainly non-null.
//
// A row is present in the output only if the condition evaluates to true. So
// here we can assume that the expression evaluates to true, and with that
// information find a list of expressions that are certainly not null.
//
function getNonNullSubExpressionsFromRowCond(expression, logicalNegation = false) {

@@ -379,10 +384,9 @@ if (expression == null) {

},
inOp: () => {
// TODO For the IN operator (expr IN (subquery), expr IN (exprlist)) we could infer
// that expr is non-nullable if we could say something about the nullability of the
// sole column of the scalar subquery or the expressions in exprlist. Currently this
// function doesn't have enough info about the query to call getOutputColumns or
// inferExpressionNullability.
return [];
},
anySomeAll: ({ lhs }) =>
// For expr op ANY/SOME/ALL (subquery), the left hand side expr is non-null
getNonNullSubExpressionsFromRowCond(lhs),
inOp: ({ lhs }) =>
// For the IN operator (expr IN (subquery), expr IN (exprlist)) the
// left-hand side expr is non-null
getNonNullSubExpressionsFromRowCond(lhs),
});

@@ -389,0 +393,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.parenthesized = void 0;
exports.parse = exports.otherExprRhs = exports.anySomeAll = exports.parenthesized = void 0;
const Either_1 = require("fp-ts/lib/Either");

@@ -23,3 +23,3 @@ const typed_parser_1 = require("../typed-parser");

// Expressions
const arraySubQueryExpr = (0, typed_parser_1.seq)((0, token_1.reservedWord)('ARRAY'), parenthesized((0, typed_parser_1.lazy)(() => select)))((_arr, subquery) => ast_1.Expression.createArraySubQuery(subquery));
const arraySubQueryExpr = (0, typed_parser_1.seq)((0, token_1.reservedWord)('ARRAY'), parenthesized((0, typed_parser_1.lazy)(() => subquerySelect)))((_arr, subquery) => ast_1.Expression.createArraySubQuery(subquery));
const caseBranch = (0, typed_parser_1.seq)((0, token_1.reservedWord)('WHEN'), (0, typed_parser_1.lazy)(() => expression), (0, token_1.reservedWord)('THEN'), (0, typed_parser_1.lazy)(() => expression))((_when, condition, _then, result) => ({ condition, result }));

@@ -51,3 +51,3 @@ const caseElse = (0, typed_parser_1.seq2)((0, token_1.reservedWord)('ELSE'), (0, typed_parser_1.lazy)(() => expression));

const parameterExpr = (0, typed_parser_1.seq)((0, token_1.symbolKeepWS)('$'), (0, typed_parser_1.int)('[0-9]+'), token_1._)((_$, index, _ws) => ast_1.Expression.createParameter(index));
const parenthesizedSubqueryOrExpr = parenthesized((0, typed_parser_1.oneOf)((0, typed_parser_1.seq)((0, typed_parser_1.lazy)(() => select))(ast_1.Expression.createScalarSubQuery), (0, typed_parser_1.lazy)(() => expression)));
const parenthesizedSubqueryOrExpr = parenthesized((0, typed_parser_1.oneOf)((0, typed_parser_1.seq)((0, typed_parser_1.lazy)(() => subquerySelect))(ast_1.Expression.createScalarSubQuery), (0, typed_parser_1.lazy)(() => expression)));
const primaryExpr = (0, typed_parser_1.seq)((0, typed_parser_1.oneOf)(arraySubQueryExpr, caseExpr, (0, typed_parser_1.attempt)((0, special_functions_1.specialFunctionCall)((0, typed_parser_1.lazy)(() => primaryExpr))), (0, typed_parser_1.attempt)(typecasts_1.prefixTypeCast), columnRefOrFunctionCallExpr, constantExpr, parameterExpr, parenthesizedSubqueryOrExpr), (0, utils_1.optional)(typecasts_1.psqlTypeCast))((expr, typeCast) => typeCast != null ? ast_1.Expression.createTypeCast(expr, typeCast) : expr);

@@ -68,9 +68,14 @@ function makeUnaryOp(oper, nextExpr) {

const addSubExpr = makeBinaryOp(oneOfOperators('+', '-'), mulDivModExpr);
const existsExpr = (0, typed_parser_1.seq)((0, token_1.reservedWord)('EXISTS'), parenthesized((0, typed_parser_1.lazy)(() => select)))((_exists, subquery) => ast_1.Expression.createExistsOp(subquery));
const existsExpr = (0, typed_parser_1.seq)((0, token_1.reservedWord)('EXISTS'), parenthesized((0, typed_parser_1.lazy)(() => subquerySelect)))((_exists, subquery) => ast_1.Expression.createExistsOp(subquery));
exports.anySomeAll = (0, typed_parser_1.seq)((0, typed_parser_1.oneOf)((0, token_1.reservedWord)('ANY'), (0, token_1.reservedWord)('SOME'), (0, token_1.reservedWord)('ALL')), parenthesized((0, typed_parser_1.lazy)(() => subquerySelect)))((comparison, subquery) => ({
kind: 'AnySomeAll',
comparison,
subquery,
}));
var OtherExprRhs;
(function (OtherExprRhs) {
const in_ = (0, typed_parser_1.seq)((0, typed_parser_1.attempt)((0, typed_parser_1.oneOf)((0, token_1.reservedWord)('IN'), (0, typed_parser_1.seqConst)('NOT IN', (0, token_1.reservedWord)('NOT'), (0, token_1.reservedWord)('IN')))), parenthesized((0, typed_parser_1.oneOf)((0, typed_parser_1.map)(ast_1.Expression.createInSubquery, (0, typed_parser_1.lazy)(() => select)), (0, typed_parser_1.map)(ast_1.Expression.createInExprList, (0, typed_parser_1.sepBy1)((0, token_1.symbol)(','), (0, typed_parser_1.lazy)(() => expression))))))((op, rhs) => ({ kind: 'InExprRhs', op, rhs }));
const ternary = (0, typed_parser_1.seq)((0, typed_parser_1.oneOf)((0, typed_parser_1.attempt)((0, token_1.sepReserveds)('NOT BETWEEN SYMMETRIC')), (0, typed_parser_1.attempt)((0, token_1.sepReserveds)('BETWEEN SYMMETRIC')), (0, typed_parser_1.attempt)((0, token_1.sepReserveds)('NOT BETWEEN')), (0, typed_parser_1.attempt)((0, token_1.reservedWord)('BETWEEN'))), addSubExpr, (0, token_1.reservedWord)('AND'), addSubExpr)((op, rhs1, _and, rhs2) => ({ kind: 'TernaryExprRhs', op, rhs1, rhs2 }));
const unarySuffix = (0, typed_parser_1.seqConst)({ kind: 'UnarySuffix', op: '!' }, (0, token_1.operator)('!'));
const otherOp = (0, typed_parser_1.seq)((0, typed_parser_1.oneOf)((0, token_1.anyOperatorExcept)([
OtherExprRhs.in_ = (0, typed_parser_1.seq)((0, typed_parser_1.attempt)((0, typed_parser_1.oneOf)((0, token_1.reservedWord)('IN'), (0, typed_parser_1.seqConst)('NOT IN', (0, token_1.reservedWord)('NOT'), (0, token_1.reservedWord)('IN')))), parenthesized((0, typed_parser_1.oneOf)((0, typed_parser_1.map)(ast_1.Expression.createInSubquery, (0, typed_parser_1.lazy)(() => subquerySelect)), (0, typed_parser_1.map)(ast_1.Expression.createInExprList, (0, typed_parser_1.sepBy1)((0, token_1.symbol)(','), (0, typed_parser_1.lazy)(() => expression))))))((op, rhs) => ({ kind: 'InExprRhs', op, rhs }));
OtherExprRhs.ternary = (0, typed_parser_1.seq)((0, typed_parser_1.oneOf)((0, typed_parser_1.attempt)((0, token_1.sepReserveds)('NOT BETWEEN SYMMETRIC')), (0, typed_parser_1.attempt)((0, token_1.sepReserveds)('BETWEEN SYMMETRIC')), (0, typed_parser_1.attempt)((0, token_1.sepReserveds)('NOT BETWEEN')), (0, typed_parser_1.attempt)((0, token_1.reservedWord)('BETWEEN'))), addSubExpr, (0, token_1.reservedWord)('AND'), addSubExpr)((op, rhs1, _and, rhs2) => ({ kind: 'TernaryExprRhs', op, rhs1, rhs2 }));
OtherExprRhs.unarySuffix = (0, typed_parser_1.seqConst)({ kind: 'UnarySuffix', op: '!' }, (0, token_1.operator)('!'));
OtherExprRhs.otherOp = (0, typed_parser_1.oneOf)((0, typed_parser_1.seq)((0, token_1.anyOperatorExcept)([
'<',

@@ -88,4 +93,10 @@ '>',

'^',
]), (0, token_1.sepReserveds)('IS DISTINCT FROM'), (0, token_1.sepReserveds)('IS NOT DISTINCT FROM'), (0, token_1.reservedWord)('LIKE')), addSubExpr)((op, rhs) => ({ kind: 'OtherOpExprRhs', op, rhs }));
OtherExprRhs.parser = (0, typed_parser_1.oneOf)(in_, ternary, unarySuffix, otherOp);
]), (0, typed_parser_1.oneOf)(exports.anySomeAll, addSubExpr))((op, rhs) => rhs.kind === 'AnySomeAll'
? {
kind: 'AnySomeAllRhs',
op,
comparison: rhs.comparison,
subquery: rhs.subquery,
}
: { kind: 'OtherOpExprRhs', op, rhs }), (0, typed_parser_1.seq)((0, typed_parser_1.oneOf)((0, token_1.sepReserveds)('IS DISTINCT FROM'), (0, token_1.sepReserveds)('IS NOT DISTINCT FROM'), (0, token_1.reservedWord)('LIKE')), addSubExpr)((op, rhs) => ({ kind: 'OtherOpExprRhs', op, rhs })));
function createExpression(lhs, rhs) {

@@ -99,2 +110,4 @@ switch (rhs.kind) {

return ast_1.Expression.createUnaryOp(rhs.op, lhs);
case 'AnySomeAllRhs':
return ast_1.Expression.createAnySomeAll(lhs, rhs.op, rhs.comparison, rhs.subquery);
case 'OtherOpExprRhs':

@@ -106,5 +119,8 @@ return ast_1.Expression.createBinaryOp(lhs, rhs.op, rhs.rhs);

})(OtherExprRhs || (OtherExprRhs = {}));
const otherExpr = (0, typed_parser_1.seq)(addSubExpr, (0, typed_parser_1.many)(OtherExprRhs.parser))((first, rest) => rest.reduce((acc, val) => OtherExprRhs.createExpression(acc, val), first));
exports.otherExprRhs = (0, typed_parser_1.oneOf)(OtherExprRhs.in_, OtherExprRhs.ternary, OtherExprRhs.unarySuffix, OtherExprRhs.otherOp);
const otherExpr = (0, typed_parser_1.seq)(addSubExpr, (0, typed_parser_1.many)(exports.otherExprRhs))((first, rest) => rest.reduce((acc, val) => OtherExprRhs.createExpression(acc, val), first));
const existsOrOtherExpr = (0, typed_parser_1.oneOf)(existsExpr, otherExpr);
const comparisonExpr = makeBinaryOp(oneOfOperators('<', '>', '=', '<=', '>=', '<>'), existsOrOtherExpr);
const comparisonExpr = (0, typed_parser_1.seq)(existsOrOtherExpr, (0, typed_parser_1.many)((0, typed_parser_1.seq)(oneOfOperators('<', '>', '=', '<=', '>=', '<>'), (0, typed_parser_1.oneOf)(exports.anySomeAll, existsOrOtherExpr))((op, next) => ({ op, next }))))((first, rest) => rest.reduce((acc, val) => val.next.kind === 'AnySomeAll'
? ast_1.Expression.createAnySomeAll(acc, val.op, val.next.comparison, val.next.subquery)
: ast_1.Expression.createBinaryOp(acc, val.op, val.next), first));
const isExpr = (0, typed_parser_1.seq)(comparisonExpr, (0, utils_1.optional)((0, typed_parser_1.oneOf)((0, token_1.sepReserveds)('IS NULL'), (0, token_1.sepReserveds)('IS NOT NULL'), (0, token_1.reservedWord)('ISNULL'), (0, token_1.reservedWord)('NOTNULL'), (0, token_1.sepReserveds)('IS TRUE'), (0, token_1.sepReserveds)('IS NOT TRUE'), (0, token_1.sepReserveds)('IS FALSE'), (0, token_1.sepReserveds)('IS NOT FALSE'), (0, token_1.sepReserveds)('IS UNKNOWN'), (0, token_1.sepReserveds)('IS NOT UNKNOWN'))))((next, op) => (op ? ast_1.Expression.createUnaryOp(op, next) : next));

@@ -166,3 +182,4 @@ const notExpr = makeUnaryOp((0, token_1.reservedWord)('NOT'), isExpr);

const selectSetOps = (0, typed_parser_1.many)((0, typed_parser_1.seq)((0, typed_parser_1.oneOf)((0, token_1.reservedWord)('UNION'), (0, token_1.reservedWord)('INTERSECT'), (0, token_1.reservedWord)('EXCEPT')), (0, utils_1.optional)((0, typed_parser_1.oneOf)((0, token_1.reservedWord)('ALL'), (0, token_1.reservedWord)('DISTINCT'))), selectBody)((op, duplicates, body) => ast_1.SelectOp.create(op, duplicates || 'DISTINCT', body)));
const select = (0, typed_parser_1.seq)((0, utils_1.optional)(withQueries), selectBody, selectSetOps, (0, utils_1.optional)(orderBy), (0, utils_1.optional)(limit))((withQueries, body, setOps, orderBy, limit) => ast_1.Select.create(withQueries || [], body, setOps, orderBy || [], limit));
const select = (0, typed_parser_1.seq)(selectBody, selectSetOps, (0, utils_1.optional)(orderBy), (0, utils_1.optional)(limit))((body, setOps, orderBy, limit) => (withQueries) => ast_1.Select.create(withQueries, body, setOps, orderBy || [], limit));
const subquerySelect = (0, typed_parser_1.seq)((0, utils_1.optional)(withQueries), select)((withQueries, select) => select(withQueries !== null && withQueries !== void 0 ? withQueries : []));
// INSERT

@@ -178,12 +195,12 @@ const defaultValues = (0, typed_parser_1.seq)((0, token_1.reservedWord)('DEFAULT'), (0, token_1.reservedWord)('VALUES'))((_def, _val) => ast_1.Values.defaultValues);

const insertInto = (0, typed_parser_1.seq3)((0, token_1.reservedWord)('INSERT'), (0, token_1.reservedWord)('INTO'), tableRef);
const insert = (0, typed_parser_1.seq)((0, utils_1.optional)(withQueries), insertInto, (0, utils_1.optional)(reqAs), (0, utils_1.optional)(identifierList), (0, typed_parser_1.oneOf)(values, (0, typed_parser_1.lazy)(() => select)), (0, utils_1.optional)(onConflict), (0, utils_1.optional)(returning))((withQueries, table, as, columns, values, onConflict, returning) => ast_1.Insert.create(withQueries || [], table, as, columns || [], values, onConflict || [], returning || []));
const insert = (0, typed_parser_1.seq)(insertInto, (0, utils_1.optional)(reqAs), (0, utils_1.optional)(identifierList), (0, typed_parser_1.oneOf)(values, (0, typed_parser_1.lazy)(() => subquerySelect)), (0, utils_1.optional)(onConflict), (0, utils_1.optional)(returning))((table, as, columns, values, onConflict, returning) => (withQueries) => ast_1.Insert.create(withQueries || [], table, as, columns || [], values, onConflict || [], returning || []));
// UPDATE
const updateAssignments = (0, typed_parser_1.seq2)((0, token_1.reservedWord)('SET'), (0, typed_parser_1.sepBy1)((0, token_1.symbol)(','), (0, typed_parser_1.seq)(token_1.identifier, (0, token_1.symbol)('='), expression)((columnName, _eq, value) => ({ columnName, value }))));
const updateTable = (0, typed_parser_1.seq2)((0, token_1.reservedWord)('UPDATE'), tableRef);
const update = (0, typed_parser_1.seq)((0, utils_1.optional)(withQueries), updateTable, (0, utils_1.optional)(as), updateAssignments, (0, utils_1.optional)(from), (0, utils_1.optional)(where), (0, utils_1.optional)(returning))((withQueries, table, as, updates, from, where, returning) => ast_1.Update.create(withQueries || [], table, as, updates, from, where, returning || []));
const update = (0, typed_parser_1.seq)(updateTable, (0, utils_1.optional)(as), updateAssignments, (0, utils_1.optional)(from), (0, utils_1.optional)(where), (0, utils_1.optional)(returning))((table, as, updates, from, where, returning) => (withQueries) => ast_1.Update.create(withQueries, table, as, updates, from, where, returning || []));
// DELETE
const deleteFrom = (0, typed_parser_1.seq3)((0, token_1.reservedWord)('DELETE'), (0, token_1.reservedWord)('FROM'), tableRef);
const delete_ = (0, typed_parser_1.seq)(deleteFrom, (0, utils_1.optional)(reqAs), (0, utils_1.optional)(where), (0, utils_1.optional)(returning))((table, as, where, returning) => ast_1.Delete.create(table, as, where, returning || []));
const delete_ = (0, typed_parser_1.seq)(deleteFrom, (0, utils_1.optional)(reqAs), (0, utils_1.optional)(where), (0, utils_1.optional)(returning))((table, as, where, returning) => (withQueries) => ast_1.Delete.create(withQueries, table, as, where, returning || []));
// parse
const statementParser = (0, typed_parser_1.seq1)((0, typed_parser_1.oneOf)((0, typed_parser_1.attempt)(select), (0, typed_parser_1.attempt)(insert), (0, typed_parser_1.attempt)(update), delete_), (0, utils_1.optional)((0, token_1.symbol)(';')));
const statementParser = (0, typed_parser_1.seq)((0, utils_1.optional)(withQueries), (0, typed_parser_1.oneOf)(select, insert, update, delete_), (0, utils_1.optional)((0, token_1.symbol)(';')))((withQueries, stmt) => stmt(withQueries !== null && withQueries !== void 0 ? withQueries : []));
const topLevelParser = (0, typed_parser_1.seq2)(token_1._, statementParser, typed_parser_1.end);

@@ -190,0 +207,0 @@ function parse(source) {

@@ -308,7 +308,2 @@ "use strict";

exports.end = end;
/**
* Succeeds when one of given parsers succeeds.
* Note that no fallback will occur if any one of them consumes even a single character.
* (See also `attempt()`)
*/
function oneOf(...parsers) {

@@ -315,0 +310,0 @@ return (source, context) => {

{
"name": "sqltyper",
"version": "1.3.1",
"version": "1.3.2",
"description": "Typed SQL queries in PostgreSQL",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

Sorry, the diff of this file is not supported yet

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