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 the release retention error #5162

Merged

Conversation

nobodyiam
Copy link
Member

@nobodyiam nobodyiam commented Jun 15, 2024

What's the purpose of this PR

Fix the release retention error

Which issue(s) this PR fixes:

Fixes #5161

Brief changelog

  • escape the table names in @SQLDelete statements

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Update the CHANGES log.

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an error related to the configuration retention feature.
  • Refactor

    • Updated SQL delete statements across various entities to ensure proper table naming by including backticks, improving SQL compatibility.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 15, 2024
Copy link
Contributor

coderabbitai bot commented Jun 15, 2024

Walkthrough

In version 2.3.0 of Apollo, a critical fix was implemented to resolve SQL errors associated with the configuration retention feature in MySQL. This involved updating SQL delete statements in entity classes to properly escape table names using backticks (`).

Changes

Files Change Summary
apollo-biz/src/.../AccessKey.java, .../Audit.java, ... Updated SQL delete statements to include backticks around table names to ensure SQL compatibility.
apollo-common/src/.../App.java, .../AppNamespace.java Adjusted SQL delete statements to use backticks for table names in the @SQLDelete annotation.
apollo-portal/src/.../Consumer.java, .../Permission.java, ... Modified SQL delete statements to correctly reference table names with backticks for integrity.

Assessment against linked issues

Objective (Issue #5161) Addressed Explanation
Fix error in SQL syntax for MySQL compatibility
Ensure all affected entity classes have updated SQL

Poem

In a world of tables where queries might fail,
SQL syntax errors would often prevail.
Apollo now escapes with backticks in place,
Making sure all deletes run with grace.
A fix for retention, debugged and refined,
Version 2.3.0, stability you'll find.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (3)
CHANGES.md (3)

16-16: Add a blank line above this entry to adhere to markdown best practices.

* [Fix the error occurred when using configuration retention feature](https://github.com/apolloconfig/apollo/pull/5162)

Line range hint 1-1: Surround headings with blank lines for better markdown formatting.

Changes by Version

Line range hint 8-8: Surround the list of changes with blank lines to meet markdown formatting standards.

* [Fix circular references on LdapAutoConfiguration](https://github.com/apolloconfig/apollo/pull/5055)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e1fe2d and 3a8d31d.

Files selected for processing (23)
  • CHANGES.md (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java (1 hunks)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java (1 hunks)
  • apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java (1 hunks)
  • apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java (1 hunks)
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java (1 hunks)
Files skipped from review due to trivial changes (12)
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/AccessKey.java
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Audit.java
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Namespace.java
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ReleaseHistory.java
  • apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/ServerConfig.java
  • apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/AppNamespace.java
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerRole.java
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Favorite.java
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java
  • apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java
Additional context used
Markdownlint
CHANGES.md

1-1: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


8-8: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines

Additional comments not posted (10)
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Privilege.java (1)

30-30: Ensure the IsDeleted flag and DeletedAt timestamp are updated correctly in your business logic to reflect these changes.

apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/ConsumerToken.java (1)

35-35: This change aligns with the overall strategy of using backticks for table names. Good job ensuring SQL compatibility.

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Cluster.java (1)

33-33: The updated SQLDelete annotation correctly uses backticks and follows the new deletion logic pattern. This change ensures consistency across your entity classes.

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/ServerConfig.java (1)

36-36: The use of backticks around the table name in the SQLDelete annotation is a good practice for SQL compatibility, especially for MySQL.

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Commit.java (1)

31-31: Escaping the table name in the SQLDelete statement helps prevent SQL syntax errors in environments like MySQL.

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Item.java (1)

31-31: Good practice to escape table names in SQL statements to avoid potential SQL syntax issues.

apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/entity/Consumer.java (1)

30-30: Correct use of backticks in the SQLDelete statement to ensure SQL syntax compatibility across different database systems.

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/GrayReleaseRule.java (1)

30-30: Correctly updated the SQLDelete statement to escape the table name, which should prevent potential SQL syntax issues.

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/entity/Release.java (1)

34-34: Correctly updated the SQLDelete statement to escape the table name Release, which is crucial given that "Release" could be a reserved SQL keyword.

apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java (1)

33-33: Correctly updated the SQLDelete statement to escape the table name App, enhancing SQL syntax safety.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 15, 2024
@shoothzj
Copy link
Member

Thanks for this fix

@nobodyiam nobodyiam merged commit 49bd8cc into apolloconfig:master Jun 16, 2024
7 checks passed
@nobodyiam nobodyiam deleted the fix-release-retention-error branch June 16, 2024 06:15
@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error occurred when using configuration retention feature
2 participants