Skip to content

Commit 9414016

Browse files
authored
HCK-3074: PostgreSQL: add db version check for security_invoker to be… (#43)
* HCK-3074: PostgreSQL: add db version check for security_invoker to be able to be included into ddl script * HCK-3074: PostgreSQL: remove tabs * HCK-3074: PostgreSQL plugin: edit security_invoker ternary operator formatting * HCK-3074: PostgreSQL plugin: edit formatting * HCK-3074: PostgreSQL plugin: edit redundant indents for security_invoker ternary
1 parent fdfc267 commit 9414016

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

forward_engineering/ddlProvider.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ module.exports = (baseProvider, options, app) => {
425425
? commentIfDeactivated(dividedColumns.deactivatedItems.join(',\n\t\t'), {
426426
isActivated: false,
427427
isPartOfLine: true,
428-
})
428+
})
429429
: '';
430430
columnsAsString = dividedColumns.activatedItems.join(',\n\t\t') + deactivatedColumnsString;
431431
}
@@ -435,13 +435,15 @@ module.exports = (baseProvider, options, app) => {
435435
: assignTemplates(templates.viewSelectStatement, {
436436
tableName: tables.join(', '),
437437
keys: columnsAsString,
438-
});
438+
});
439439

440440
const check_option = viewData.viewOptions?.check_option
441441
? `check_option=${viewData.viewOptions?.check_option}`
442442
: '';
443443
const security_barrier = viewData.viewOptions?.security_barrier ? `security_barrier` : '';
444-
const security_invoker = viewData.viewOptions?.security_invoker ? 'security_invoker' : '';
444+
const dbVersionWhereSecurityInvokerAppeared = 15;
445+
const security_invoker = viewData.viewOptions?.security_invoker &&
446+
getDbVersion(dbData.dbVersion) >= dbVersionWhereSecurityInvokerAppeared ? 'security_invoker' : '';
445447
const withOptions =
446448
check_option || security_barrier || security_invoker
447449
? `\n\tWITH (${_.compact([check_option, security_barrier, security_invoker]).join(',')})`
@@ -673,4 +675,4 @@ module.exports = (baseProvider, options, app) => {
673675
return statement;
674676
},
675677
};
676-
};
678+
};

0 commit comments

Comments
 (0)