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

refactor: A new dockerfile for the connector, restructuring of the codebase, sorting of the imports #55

Merged
merged 4 commits into from
Aug 8, 2023

Conversation

Joel-hanson
Copy link
Contributor

Description

Reafactor the code to move all the command build related method to a different class

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Joel-hanson Joel-hanson changed the title Refactoring Latest changes for refactoring the source code Jul 18, 2023
@Joel-hanson Joel-hanson changed the title Latest changes for refactoring the source code refactor: A new dockerfile for the connector, restructuring of the codebase, sorting of the imports Aug 1, 2023
Copy link
Contributor

@jhughes24816 jhughes24816 left a comment

Choose a reason for hiding this comment

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

A couple of tidy up suggestions left

@@ -0,0 +1,172 @@
package com.ibm.eventstreams.connect.jdbcsink.database.builder;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy right headers are required at the top of new files and edited files will need updating


public IDataSource dataSource = null;

public CommandBuilder(IDataSource connection) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These names are not quite lined up. Either the object is a data source or it is a connection to the data source? Would it be possible to clarify this?

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 have split out class into command builder and database factory which makes it having individual behavior.

sb.append("INSERT INTO ").append(tableName);
sb.append("(").append(String.join(", ", fieldNames)).append(")");
sb.append(" VALUES ");
sb.append("(").append(String.join(", ", Collections.nCopies(fieldNames.size(), "?"))).append(")");
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have any command builder tests? It is not clear why we are adding an n fold collection of "?" to this command some tests would make this class easier to understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The preparestatement replaces those ? with values for example.

PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
                                     SET SALARY = ? WHERE ID = ?");
   pstmt.setBigDecimal(1, 153833.00)
   pstmt.setInt(2, 110592)

Copy link
Contributor

@jhughes24816 jhughes24816 left a comment

Choose a reason for hiding this comment

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

LGTM, nice work Joel!

@jhughes24816 jhughes24816 merged commit 34f3138 into ibm-messaging:main Aug 8, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants