Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const mapColumnCheckConstraintsToChangeHistory = collection => {
* */
const getDropColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName) => {
return constraintHistory
.filter(historyEntry => historyEntry.old && !historyEntry.new)
.filter(historyEntry => historyEntry.old?.expression && !historyEntry.new?.expression)
.map(historyEntry => {
const wrappedConstraintName = getConstraintName(
historyEntry.old.name,
Expand All @@ -124,7 +124,7 @@ const getDropColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName
* */
const getAddColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName) => {
return constraintHistory
.filter(historyEntry => historyEntry.new && !historyEntry.old)
.filter(historyEntry => historyEntry.new?.expression && !historyEntry.old?.expression)
.map(historyEntry => {
const { name, expression, noInherit } = historyEntry.new;
const constraintName = getConstraintName(name, historyEntry.columnName, fullTableName);
Expand All @@ -142,7 +142,7 @@ const getAddColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName)
const getUpdateColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName) => {
return constraintHistory
.filter(historyEntry => {
if (historyEntry.old && historyEntry.new) {
if (historyEntry.old?.expression && historyEntry.new?.expression) {
const oldExpression = historyEntry.old.expression;
const newExpression = historyEntry.new.expression;
const oldNoInherit = historyEntry.old.noInherit;
Expand Down
7 changes: 5 additions & 2 deletions forward_engineering/ddlProvider/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,12 @@ module.exports = (baseProvider, options, app) => {
const defaultValue = !_.isUndefined(columnDefinition.default)
? ' DEFAULT ' + decorateDefault(type, columnDefinition.default, isArrayType)
: '';
const checkConstraint = !_.isEmpty(columnDefinition.checkConstraint)
? ' ' + this.createCheckConstraint(_.first(columnDefinition.checkConstraint)).trim()

const checkConstraintData = _.first(columnDefinition.checkConstraint);
const checkConstraint = checkConstraintData?.expression
? ' ' + this.createCheckConstraint(checkConstraintData).trim()
: '';

const generatedColumnClause =
columnDefinition.dbVersion >= 12 &&
columnDefinition.generatedColumn &&
Expand Down