Parameters that you pass to the Query.filter function are eventually
going to be rendered into an SQL statement, so your is_id_valid
function probably needs to return something built from SQLAlchemy's
SQL expression language:
https://docs.sqlalchemy.org/en/14/core/tutorial.html

If you can explain the sort of validation that is_id_valid needs to
do, we might be able to help more.

Simon


On Wed, Apr 28, 2021 at 6:33 AM Gyanaranjan Nayak <gngy...@gmail.com> wrote:
>
> I have a function with name is_id_valid(id) which returns either True or 
> False.
>
> I want to pass this function inside a sqlalchemy query inside the filter 
> condition.
> My query example is :
>
> a = session.query(GeneralBeqReq).filter(GeneralBeqReq.c.BeqReqStatus == 1,
>    is_id_valid (GeneralBeqReq.c.id) == True).all()
>
> When I run the above query It is throwing the following error.
>
> AttributeError: Neither 'Column' object nor 'Comparator' object has an 
> attribute 'strip'
>
>
> Can you please guide me how to use this function inside my query ?
>
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> ---
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/f388cfb8-0b0d-4ab3-8e26-84c4eb91b4a9n%40googlegroups.com.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexctFbqaWWaSFG7QZ8kkX-Fr7N71NtBfb4FXYv8nkjfPwQ%40mail.gmail.com.

Reply via email to