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

RelationalBone defaultValue not working #1152

Open
phorward opened this issue May 6, 2024 · 2 comments
Open

RelationalBone defaultValue not working #1152

phorward opened this issue May 6, 2024 · 2 comments
Labels
bug(fix) Something isn't working or address a specific issue or vulnerability Priority: Medium This issue may be useful, and needs some attention.

Comments

@phorward
Copy link
Member

phorward commented May 6, 2024

When defining this bone

    agent = RelationalBone(
        kind="user",
        descr="Benutzer",
        searchable=True,
        defaultValue=lambda *_: current.user.get() and current.user.get()["key"]
    )

it seems that the returned default value is not being processed.
Maybe the format is wrong, but there's also no error message or any other useful hint.

@phorward phorward added the bug(fix) Something isn't working or address a specific issue or vulnerability label May 6, 2024
phorward added a commit to phorward/viur-core that referenced this issue May 6, 2024
- Checks default value for matching type
- Allows to set RelationalBone default via key-only (fixes viur-framework#1152)
- TODO: Default values with languages currently not supported
@sveneberth
Copy link
Member

If I remember correctly, this worked for me recently. It's actually also quite intuitive 😂

defaultValue=lambda skel, bone: current.user.get() and bone.singleValueUnserialize(bone.createRelSkelFromKey(
    current.user.get()["key"]
)),

@phorward
Copy link
Member Author

phorward commented May 8, 2024

It's actually also quite intuitive 😂

It's totally intuitive, as all is in this great piece of shit software. This is how I resolved it now. Obvious and understandable for everyone.

    agent = UserBone(
        descr="Benutzer",
        searchable=True,
        defaultValue=lambda *_: current.user.get() and TicketSkel.agent.createRelSkelFromKey(current.user.get()["key"]),
    )

@phorward phorward added the Priority: Medium This issue may be useful, and needs some attention. label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug(fix) Something isn't working or address a specific issue or vulnerability Priority: Medium This issue may be useful, and needs some attention.
Projects
None yet
Development

No branches or pull requests

2 participants