Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion forward_engineering/configs/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {

spatialIndex: 'CREATE SPATIAL INDEX ${name} ON ${table} (${column})${using}\n${options}${terminator}\n',

checkConstraint: 'CONSTRAINT [${name}] CHECK${notForReplication} (${expression})',
checkConstraint: 'CONSTRAINT [${name}] ${check}${notForReplication} (${expression})',

createForeignKeyConstraint:
'CONSTRAINT ${name} FOREIGN KEY (${foreignKey}) REFERENCES ${primaryTable} (${primaryKey}) ${onDelete}${onUpdate}',
Expand Down
2 changes: 2 additions & 0 deletions forward_engineering/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ module.exports = (baseProvider, options, app) => {
createCheckConstraint(checkConstraint) {
return assignTemplates(templates.checkConstraint, {
name: checkConstraint.name,
check: checkConstraint.check ? 'CHECK' : 'NO CHECK',
notForReplication: checkConstraint.enforceForReplication ? '' : ' NOT FOR REPLICATION',
expression: _.trim(checkConstraint.expression).replace(/^\(([\s\S]*)\)$/, '$1'),
terminator,
Expand Down Expand Up @@ -533,6 +534,7 @@ module.exports = (baseProvider, options, app) => {
hydrateCheckConstraint(checkConstraint) {
return {
name: checkConstraint.chkConstrName,
check: checkConstraint.constrCheck,
expression: checkConstraint.constrExpression,
existingData: checkConstraint.constrCheck,
enforceForUpserts: checkConstraint.constrEnforceUpserts,
Expand Down
2 changes: 1 addition & 1 deletion forward_engineering/helpers/columnDefinitionHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = app => {

const decorateDefault = (type, defaultValue) => {
if (isString(type) && defaultValue !== 'NULL') {
return `'${escapeQuotes(defaultValue)}'`;
return escapeQuotes(defaultValue);
} else if (type === 'XML') {
return `CAST(N'${defaultValue}' AS xml)`;
}
Expand Down