Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for DAT-15716 :: Include 'OR REPLACE' instruction for a view when generate-changelog/diff-changelog command are executed #5304

Merged
merged 17 commits into from Dec 19, 2023

Conversation

MalloD12
Copy link
Contributor

@MalloD12 MalloD12 commented Nov 30, 2023

USE_OR_REPLACE_OPTION command argument added to control whether we want to include OR REPLACE SQL instruction for a VIEW when executing a generate-changelog or diff-changelog command.

Integration tests were added for both commands.

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Things to be aware of

  • None

Things to worry about

  • None

Additional Context

…sing generate-changelog or diff-changelog commands.
@MalloD12 MalloD12 self-assigned this Nov 30, 2023
@suryaaki2 suryaaki2 marked this pull request as draft November 30, 2023 20:33
@MalloD12 MalloD12 marked this pull request as ready for review December 4, 2023 16:24
Comment on lines 430 to 432
If true, will add 'OR REPLACE' option to the given
stored logic change object for example, create
view, create procedure, etc.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include something in the description that says how it will play with the --always-drop-instead-of-replace argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I haven't tested this change alongside that other existent configuration. I'll do that and see how to provide a better description for this new config.

Thanks,
Daniel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't updated this one yet, I'm trying to check this one with Mario. I think there is no relationship between these two configurations If I'm not wrong ALWAYS_DROP_INSTEAD_OF_REPLACE is mostly used for update command (for example, when changing the structure of a view and we don't want to get an error in the try of updating a new version of it). Whereas the new USE_OR_REPLACE_OPTION configuration is used for generate-changelog and diff-changelog commands.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably explain that in the description, at least in the description of the property that you're adding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I finally removed that global configuration and instead added it as a command argument of both (generate-changelog and diff-changelog) commands respectively. We should also reflect this in the docs.

Copy link
Collaborator

@filipelautert filipelautert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add the two @OverRide requested by codeQL

- Close DB connection on DiffChangelog integration tests.
- Command argument description updated.
@MalloD12
Copy link
Contributor Author

MalloD12 commented Dec 12, 2023

Guys, as discussed in DAT-15716 I have added support in this PR for using useOrReplaceOption property in mvn for generate-changelog and diff-changelog. Could you please have a look at those changes?

Thanks,
Daniel.

Copy link
Collaborator

@filipelautert filipelautert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fine

Comment on lines +49 to +53
USE_OR_REPLACE_OPTION = builder.argument("useOrReplaceOption", Boolean.class)
.description("If true, will add 'OR REPLACE' option to the create view change object")
.defaultValue(false)
.setValueHandler(ValueHandlerUtil::booleanValueHandler)
.build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't necessary for this PR, but instead of repeating the argument, you can make a new class that extends AbstractArgumentCommandStep, and then specify that as a requiresDependency here and in every other class which requires this argument. This helps to reduce the code duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created an abstract class with some common behavior that GenerateChangelogCommandStep and DiffChangelogCommandStep both use, I was thinking once that PR is merged to move this new argument there, and then in these two command classes do this:

builder.addArgument(AbstractChangelogCommandStep. USE_OR_REPLACE_OPTION).build();

What do you think about it?

Thanks,
Daniel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good. I don't think that's been done before, but it sounds simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is! @filipelautert showed me yesterday that was already applied to RollbackCommandStep, so I applied the same to GenerateChangelog and DiffChangelog command step classes.

@suryaaki2 suryaaki2 merged commit 182ffe5 into master Dec 19, 2023
33 checks passed
@suryaaki2 suryaaki2 deleted the DAT-15716 branch December 19, 2023 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants