UNPKG

ddl-manager

Version:

store postgres procedures and triggers in files

41 lines 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildSelfAssignBeforeInsertByOtherTablesBody = void 0; const ast_1 = require("../../../ast"); const exitIf_1 = require("./util/exitIf"); function buildSelfAssignBeforeInsertByOtherTablesBody(selectNewValues, notMatchedFilterOnInsert) { const body = new ast_1.Body({ declares: [ new ast_1.Declare({ name: "new_totals", type: "record" }) ], statements: [ new ast_1.BlankLine(), ...exitIf_1.exitIf({ if: notMatchedFilterOnInsert, blanksBefore: [new ast_1.BlankLine()] }), new ast_1.BlankLine(), new ast_1.BlankLine(), selectNewValues.clone({ intoRow: "new_totals" }), new ast_1.BlankLine(), new ast_1.BlankLine(), ...selectNewValues.columns.map(column => new ast_1.AssignVariable({ variable: `new.${column.name}`, value: new ast_1.HardCode({ sql: `new_totals.${column.name}` }) })), new ast_1.BlankLine(), new ast_1.BlankLine(), new ast_1.HardCode({ sql: `return new;` }) ] }); return body; } exports.buildSelfAssignBeforeInsertByOtherTablesBody = buildSelfAssignBeforeInsertByOtherTablesBody; //# sourceMappingURL=buildSelfAssignBeforeInsertByOtherTablesBody.js.map