Hi,

I'm puzzled on how to get this working:


class User(base):
        Id                      =       Column (Integer, primarykey=true)
        Name            =       Column(Unicode(100))


Session.query(User).filter(User.Name.like(query+"%")).all()

is all fine.

now I want to add an extension to the query, which does the same within Id and 
returns all results where the Id field is searched as a string too

like

Session.query(User).filter(or_(User.Name.like("%"+query+"%"), 
str(User.Id).like(query+"%")).all()

                                                                                
                                   ^^^^
example data:


1, "martijn 1"
2, "martijn 2"
….
100,"martijn 100"



searching for "1" will find all records with Id's -> 1,11,12…., 19, 100
and records with a "1" somewhere in the name.

there must be a way, right?

Martijn

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to