Skip to content

Commit

Permalink
Merge pull request #61 from hackolade/HCK-4036--v6-11-3-alpha-1-2-add…
Browse files Browse the repository at this point in the history
…ed-support-for-if-not-exi

FE: added support of IF NOT EXISTS for CREATE USER statements on 23c
  • Loading branch information
taras-dubyk authored Sep 29, 2023
2 parents dae6dd4 + e75fbe9 commit a2310a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion forward_engineering/configs/templates.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
createSchema: 'CREATE USER ${schemaName} NO AUTHENTICATION',
createSchema: 'CREATE USER${ifNotExists} ${schemaName} NO AUTHENTICATION',

comment: '\nCOMMENT ON ${object} ${objectName} IS ${comment};\n',

Expand Down
19 changes: 13 additions & 6 deletions forward_engineering/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,22 @@ module.exports = (baseProvider, options, app) => {
};
},

createSchema({schemaName, ifNotExist}) {
const schemaStatement = wrapIfNotExists(
assignTemplates(templates.createSchema, {
schemaName: wrapInQuotes(schemaName),
}),
createSchema({schemaName, ifNotExist, dbVersion}) {
const usingTryCatchWrapper = shouldUseTryCatchIfNotExistsWrapper(dbVersion);
const schemaStatement = assignTemplates(templates.createSchema, {
schemaName: wrapInQuotes(schemaName),
ifNotExists: !usingTryCatchWrapper && ifNotExist ? ' IF NOT EXISTS' : '',
});

if (!usingTryCatchWrapper) {
return schemaStatement + ';';
}

return wrapIfNotExists(
schemaStatement,
ifNotExist,
1920,
);
return schemaStatement;
},

hydrateColumn({columnDefinition, jsonSchema, schemaData, definitionJsonSchema = {}}) {
Expand Down

0 comments on commit a2310a6

Please sign in to comment.