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

json: extract the $[last] entry from json object should also return itself #59687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YangKeao
Copy link
Member

What problem does this PR solve?

Issue Number: close #59619

Problem Summary:

json_extract('{"a":"b"}', '$[last]') should also return {"a":"b"}. It also affects the json_set and any other json functions using the path.

TiDB already handled the case for $[0], but we didn't handle this case for $[last].

What changed and how does it work?

Also return the object itself when the path is $[last], just like $[0].

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed do-not-merge/needs-triage-completed labels Feb 21, 2025
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.3632%. Comparing base (681fa36) to head (86e251f).
Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #59687        +/-   ##
================================================
+ Coverage   72.9533%   73.3632%   +0.4098%     
================================================
  Files          1697       1697                
  Lines        468909     468949        +40     
================================================
+ Hits         342085     344036      +1951     
+ Misses       105773     103833      -1940     
- Partials      21051      21080        +29     
Flag Coverage Δ
integration 42.7762% <100.0000%> (?)
unit 72.1446% <100.0000%> (-0.0035%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.1019% <ø> (-0.0029%) ⬇️

Copy link

ti-chi-bot bot commented Feb 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 21, 2025
Copy link

ti-chi-bot bot commented Feb 21, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-02-21 10:41:14.09554023 +0000 UTC m=+6822.048698489: ☑️ agreed by Defined2014.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The JSON_SET returns wrong result for empty object
2 participants