Skip to content

Magic .as_(...) operation works incorrectly with negative results #1281

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

Closed
2 tasks done
JrooTJunior opened this issue Aug 26, 2023 · 0 comments · Fixed by #1283
Closed
2 tasks done

Magic .as_(...) operation works incorrectly with negative results #1281

JrooTJunior opened this issue Aug 26, 2023 · 0 comments · Fixed by #1283
Labels
3.x Issue or PR for stable 3.x version bug Something is wrong with the framework
Milestone

Comments

@JrooTJunior
Copy link
Member

Checklist

  • I am sure the error is coming from aiogram code
  • I have searched in the issue tracker for similar bug reports, including closed ones

Operating system

Any

Python version

Any

aiogram version

3.0

Expected behavior

F.text.cast(int).as_("value") should works when text is "0"

Current behavior

0 interpreted as negative result

Steps to reproduce

  1. Send 0 as a text message

Code example

from aiogram import Router, F
from aiogram.types import Message

demo_router = Router(name=__name__)


@demo_router.message(F.text.cast(int).as_("value"))
async def zero_handler(message: Message, value: int):
    await message.answer(f"Value: {value}")

Logs

No response

Additional information

No response

@JrooTJunior JrooTJunior added bug Something is wrong with the framework 3.x Issue or PR for stable 3.x version labels Aug 26, 2023
@JrooTJunior JrooTJunior added this to the 3.0 milestone Aug 26, 2023
JrooTJunior added a commit that referenced this issue Aug 26, 2023
Modified the ".as_" method in the magic filter class to correctly handle values that are interpreted as `False` such as `0`. Previously, the method incorrectly dismissed these valid values. The issue was identified and fixed to ensure correct handling of all valid data inputs.
JrooTJunior added a commit that referenced this issue Aug 26, 2023
Modified the ".as_" method in the magic filter class to correctly handle values that are interpreted as `False` such as `0`. Previously, the method incorrectly dismissed these valid values. The issue was identified and fixed to ensure correct handling of all valid data inputs.
@github-project-automation github-project-automation bot moved this to Done in 3.0 Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issue or PR for stable 3.x version bug Something is wrong with the framework
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant