Skip to content

fix date_add with param input (#1.1-dev) - #15450

Merged
mergify[bot] merged 2 commits into
matrixorigin:1.1-devfrom
YANGGMM:fix-date-add-1.1-dev
Apr 11, 2024
Merged

mergify[bot] merged 2 commits into
matrixorigin:1.1-devfrom
YANGGMM:fix-date-add-1.1-dev

Conversation

@YANGGMM

@YANGGMM YANGGMM commented Apr 11, 2024

Copy link
Copy Markdown
Contributor

fix date_add with param input

Approved by: @heni02, @m-schen

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #15081

What this PR does / why we need it:

fix date_add with param input

fix date_add with param input

Approved by: @heni02, @m-schen
@YANGGMM
YANGGMM requested a review from a user April 11, 2024 02:05
@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Apr 11, 2024
@mergify
mergify Bot requested a review from sukki37 April 11, 2024 02:06
@mergify mergify Bot added the kind/bug Something isn't working label Apr 11, 2024
@matrix-meow

Copy link
Copy Markdown
Contributor

@YANGGMM Thanks for your contributions!

Pull Request Review:

Title:

The title of the pull request is clear and concise, indicating that it fixes an issue related to the date_add function with parameter input.

Body:

The body of the pull request provides relevant information about the type of PR, the specific issue it fixes, and why the PR is needed. It also lists the approvals from other team members, which is a good practice for transparency and collaboration.

Changes:

  1. In the list_builtIn.go file:

    • Two new overloads have been added for date_add and date_sub functions with text, int64, and int64 parameters.
    • The retType function now returns types.T_datetime.ToType() for the new overloads.
    • The newOp function is updated to return DateStringAdd and DateStringSub for the new overloads.
  2. In the temporal_interval.result file:

    • Test cases have been added to check the functionality of date_add and date_sub with intervals.
  3. In the temporal_interval.sql file:

    • Test cases have been added to test date_add and date_sub functions with intervals.

Feedback:

  1. Security Issue - SQL Injection Risk:

    • The usage of now() function in SQL queries without proper validation or sanitization can lead to SQL injection vulnerabilities. It's important to ensure that user inputs are properly sanitized or parameterized to prevent such security risks. Consider using prepared statements or input validation to mitigate this risk.
  2. Code Optimization:

    • Instead of hardcoding the interval value in the test cases (Interval 30 SECOND), consider using variables or constants to make the code more maintainable and readable.
    • It's recommended to add comments explaining the purpose of the added test cases for better code documentation.
  3. Consistency:

    • Ensure consistency in naming conventions and formatting across the codebase to maintain readability and clarity. For example, consider using consistent casing for function names and parameters.
  4. Testing Improvement:

    • It would be beneficial to include more comprehensive test cases to cover various scenarios and edge cases related to the date_add and date_sub functions to ensure robustness and reliability.
  5. Documentation:

    • Consider updating the relevant documentation or function comments to reflect the changes made in the codebase for better understanding by other developers and users.

Conclusion:

Overall, the pull request addresses the issue related to date_add function with parameter input. However, it's crucial to address the security risk related to SQL injection and consider optimizing the code for better maintainability and readability. Additionally, enhancing testing coverage and ensuring consistency in coding practices will contribute to the overall quality of the codebase.

@mergify
mergify Bot merged commit 8334b5b into matrixorigin:1.1-dev Apr 11, 2024
@YANGGMM
YANGGMM deleted the fix-date-add-1.1-dev branch May 13, 2024 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants