Skip to content

Conversation

@brfrn169
Copy link
Collaborator

Description

This PR refactors JDBC adapter related code to reduce duplication and remove unnecessary code.

Related issues and/or PRs

N/A

Changes made

  • Refactored the integration test code for JDBC adapter.
  • Merged the MergeIntoQuery and MergeQuery classes.

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

N/A

@brfrn169 brfrn169 requested a review from Copilot July 29, 2025 02:17
@brfrn169 brfrn169 self-assigned this Jul 29, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors JDBC adapter related code to reduce duplication and remove unnecessary code by merging the MergeIntoQuery and MergeQuery classes into a single unified implementation.

  • Consolidated MergeIntoQuery and MergeQuery classes into a single MergeQuery class with parameterized behavior
  • Renamed method buildSelectQuery to buildSelectWithLimitQuery for better clarity
  • Removed unused utility methods and simplified integration test code

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
QueryBuilderTest.java Updated test expectations to use "MERGE INTO" syntax instead of "MERGE" for SQL Server tests
SelectQuery.java Updated method call from buildSelectQuery to buildSelectWithLimitQuery
MergeQuery.java Enhanced to support both standard merge and merge-into functionality with configurable dual table and semicolon options
MergeIntoQuery.java Removed entire class as functionality merged into MergeQuery
RdbEngineStrategy.java Renamed interface method for better semantic clarity
RdbEngine*.java Updated implementations to use renamed method and new MergeQuery constructors
JdbcUtils.java Removed unused isSqlite utility method
JdbcSchemaLoaderImportIntegrationTest.java Simplified property initialization
JdbcEnv.java Inlined SQLite detection logic removing dependency on removed utility method

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @brfrn169, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on significant refactoring within the JDBC adapter to enhance code maintainability and reduce redundancy. Key changes include streamlining integration test configurations, consolidating the logic for generating UPSERT SQL statements into a single MergeQuery class, and standardizing method names related to select queries with limits across various RDB engine implementations.

Highlights

  • JDBC Integration Test Refactoring: Simplified the JdbcEnv.isSqlite() method and JdbcSchemaLoaderImportIntegrationTest.getProperties() to remove unnecessary object creation and dependencies, making the test setup cleaner and more direct.
  • Consolidation of UPSERT Query Logic: The MergeIntoQuery class has been removed, and its functionality, specifically for generating MERGE INTO SQL statements for different RDB engines (DB2, Oracle, SQL Server), has been integrated into the MergeQuery class. This significantly reduces code duplication and centralizes UPSERT logic.
  • Standardization of Select Query Building: The buildSelectQuery method in the RdbEngineStrategy interface and its implementations (e.g., MySQL, Oracle, PostgreSQL, SQL Server, SQLite) has been consistently renamed to buildSelectWithLimitQuery to better reflect its purpose when handling queries with limits.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a nice refactoring of the JDBC adapter code. The key changes are merging the MergeIntoQuery and MergeQuery classes to reduce duplication, and renaming buildSelectQuery to buildSelectWithLimitQuery for better clarity. These changes have been applied consistently across the codebase, including updates to tests. The removal of JdbcUtils.isSqlite and other minor cleanups also contribute to improving the code quality. The refactoring is well-executed and I have no concerns with the changes.

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@brfrn169 brfrn169 merged commit b1fdc3b into master Jul 31, 2025
56 checks passed
brfrn169 added a commit that referenced this pull request Jul 31, 2025
@brfrn169 brfrn169 deleted the refactor-jdbc-adapter-related-code branch July 31, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants