Skip to content

Fixed mutated attributes do not work in camel case#2509

Merged
limingxinleo merged 5 commits intohyperf:masterfrom
ALawating-Rex:fix_camelcase_mutated
Sep 17, 2020
Merged

Fixed mutated attributes do not work in camel case#2509
limingxinleo merged 5 commits intohyperf:masterfrom
ALawating-Rex:fix_camelcase_mutated

Conversation

@ALawating-Rex
Copy link
Copy Markdown
Contributor

当 model 里使用 use CamelCase; 同时自定义一个 访问器: getXxxAttribute 的时候,查询结果再 toArray ,其中的 Xxx 属性值没有被改变。

原因: use CamelCase; 里重写了方法 addMutatedAttributesToArray , 而这个方法判断的时候把 key 都转成了驼峰,导致 array_key_exists 始终为 false,也就是看起来这个函数没有用了。

@limingxinleo
Copy link
Copy Markdown
Member

@marunrun 看看这个

@marunrun
Copy link
Copy Markdown
Contributor

@marunrun 看看这个

这个 addMutatedAttributesToArray 确实没什么必要

@limingxinleo limingxinleo changed the title CamelCase驼峰模式下,设置访问器 getXxxAttribute , 查询结果 toArray 没有变化 Fixed mutated attributes do not work in camel case Sep 17, 2020
@limingxinleo limingxinleo merged commit 221fa54 into hyperf:master Sep 17, 2020
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