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

Error when use get_multi_joined with relationship type one-to-many #136

Open
Justinianus2001 opened this issue Jul 25, 2024 · 0 comments
Open

Comments

@Justinianus2001
Copy link

Hello, I try to get list process as follow:

processes = await crud_processes.get_multi_joined(**params)

I also define params like this:

params = {
    "db": db,
    "is_deleted": False,
    "schema_to_select": model,
    "nest_joins": True,
    "joins_config": [
        JoinConfig(
            model=LogWork,
            join_on=and_(Process.id == LogWork.process_id, LogWork.is_deleted == False),
            join_prefix="log_work_",
            schema_to_select=LogWorkRead,
            join_type="left",
            relationship_type="one-to-many",
        )
    ]
}

But get error

File "/usr/local/lib/python3.11/site-packages/fastcrud/crud/fast_crud.py", line 1478, in get_multi_joined
  nested_data = _nest_multi_join_data(
                ^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/fastcrud/crud/helper.py", line 497, in _nest_multi_join_data
  isinstance(value, dict) and value[join_primary_key] is None
                              ~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'id'

Please help me fix this, thank a lots!

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

No branches or pull requests

1 participant