yao icon indicating copy to clipboard operation
yao copied to clipboard

[Bug] 如果在一个表里有多个 hasmany 的关联关系,无法获取正常的值

Open wwsheng009 opened this issue 1 year ago • 0 comments

发生了什么?

如果在一个表里有多个 hasmany 的关联关系,无法获取正常的值

相关截图(必需)

最小可复现例子(必需)

Please provide a minimal reproduction then upload to your GitHub. 请提供 最小重现,并上传到你的 GitHub 仓库

https://github.com/wwsheng009/yao-hasmany-unexpected

复现步骤

Steps to reproduce the behavior: 1. 2.

git clone https://github.com/wwsheng009/yao-hasmany-unexpected.git
cd yao-hasmany-unexpected
yao migrate --reset

yao run yao.table.get pet '::{"withs":{"dog":{}},"withs":{"cat":{"withs":{"whitecat":{}}}}}'

错误的结果如下:

--------------------------------------
yao.table.get 返回结果
--------------------------------------
[
    {
        "dogs": [
            {
                "id": 1,
                "name": "dog  one",
                "pet_id": 1
            },
            {
                "dogs": [
                    {
                        "id": 1,
                        "name": "cat  one",
                        "pet_id": 2
                    },
                    {
                        "id": 2,
                        "name": "cat  two",
                        "pet_id": 2
                    }
                ],
                "id": 2,
                "name": "dog  two",
                "pet_id": 1
            }
        ],
        "id": 1,
        "name": "dog number one"
    },
    {
        "id": 2,
        "name": "cat number two"
    }
]

Expected behavior 1. 2.

pets:
    - dogs
    - cats
        - whitecat

Context

https://github.com/wwsheng009/yao-hasmany-unexpected

  • Yao Version( Detail Version ):yao-0.10.3-pre
  • Xgen Version( Build Info ):
  • Platform:linux

wwsheng009 avatar Apr 10 '23 08:04 wwsheng009