Skip to content

feat: support get_many with unknown key#174

Merged
liuq19 merged 1 commit intocloudwego:v0.5from
ChopinXBP:feat/get-many-with-unknown-key
Apr 9, 2025
Merged

feat: support get_many with unknown key#174
liuq19 merged 1 commit intocloudwego:v0.5from
ChopinXBP:feat/get-many-with-unknown-key

Conversation

@ChopinXBP
Copy link
Copy Markdown
Contributor

@ChopinXBP ChopinXBP commented Mar 25, 2025

What type of PR is this?

feat: support get_many with unknown key

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

Translate the PR title into Chinese.

get_many 相关方法支持入参中存在未知路径

More detailed description for this PR(en: English/zh: Chinese).

This PR enhances and break change the get_many function to handle unknown keys gracefully. The function now returns a Result<Vec<Option<LazyValue>>> instead of Result<Vec<LazyValue>>, allowing it to represent unknown keys as None values. This change improves the flexibility and robustness of the function, especially when dealing with dynamic or partially unknown JSON structures.

Breaking Changes:

  • Updated the return type from Result<Vec<LazyValue>> to Result<Vec<Option<LazyValue>>>.
  • Modified the function behavior to return None for unknown keys instead of throwing an error.

This enhancement allows users to query for multiple fields, including potentially unknown ones, without causing errors for missing keys. It provides a more flexible way to handle varying JSON structures in a single operation.

允许 get_many 相关方法的入参中存在未知路径。

不兼容变更:

  1. 当前方法的返回值类型是 Result<Vec<Option<LazyValue>>> ,变更前为 Result<Vec<LazyValue>>
  2. 当入参的某个路径在 Json String 中不存在时,当前方法会以 None 值在 Vec 中返回,变更前调用方法会直接错误并返回失败

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2025

CLA assistant check
All committers have signed the CLA.

@ChopinXBP ChopinXBP marked this pull request as draft March 25, 2025 08:19
@ChopinXBP ChopinXBP changed the base branch from main to v0.5 March 25, 2025 08:19
@ChopinXBP ChopinXBP marked this pull request as ready for review March 25, 2025 11:18
@ChopinXBP ChopinXBP changed the title WIP: feat: support get_many with unknown key feat: support get_many with unknown key Mar 25, 2025
@ChopinXBP ChopinXBP force-pushed the feat/get-many-with-unknown-key branch from 00e6248 to a99ab86 Compare March 25, 2025 13:18
@ChopinXBP ChopinXBP force-pushed the feat/get-many-with-unknown-key branch from a99ab86 to 15668d5 Compare April 9, 2025 08:58
@ChopinXBP ChopinXBP force-pushed the feat/get-many-with-unknown-key branch from 15668d5 to 214e682 Compare April 9, 2025 09:26
@liuq19 liuq19 merged commit 9ff71d9 into cloudwego:v0.5 Apr 9, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants