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

NIFI-14346 PutDatabaseRecord fails to do upsert on MySQL due to too few parameters bound #9817

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TomaszK-stack
Copy link

@TomaszK-stack TomaszK-stack commented Mar 22, 2025

This change addresses an issue in the PutDatabaseRecord processor when the Statement Type is set to UPSERT and connected to a MySQL database. The original code for binding parameters to the UPSERT SQL statement was incorrectly calculating the number of repetitions for parameter setting, leading to the error: java.sql.SQLException: No value specified for parameter 1.

Summary

NIFI-14346

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 21

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@dan-s1
Copy link
Contributor

dan-s1 commented Mar 24, 2025

@TomaszK-stack Thank you for contributing your change. Can you please keep the basic template of the PR where there should be a link to associated ticket? Also a title would help describing your fix. Thanks!

@exceptionfactory
Copy link
Contributor

@TomaszK-stack, concurring with @dan-s1, please update the pull request title and use the pull request template. The background description is very helpful, and can be preserved along with the standard template.

For the functional change itself, it would be very helpful to add a unit test to confirm the behavior. There are a number of existing tests that should provide a useful starting point.

@TomaszK-stack TomaszK-stack changed the title NIFI-14346 NIFI-14346 PutDatabaseRecord fails to do upsert on MySQL due to too few parameters bound Mar 24, 2025
@TomaszK-stack
Copy link
Author

Okay, I changed title of pr and description - now is along with standard template.
I considered writing unit tests but there but It would be hard to test working upsert on special database like MySql in this case.

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.

3 participants