Case-insensitivt søk (håper jeg).

This commit is contained in:
Øystein Ingmar Skartsæterhagen 2010-05-11 16:51:36 +00:00
parent 189af78fd5
commit e073f45919

View File

@ -5,7 +5,8 @@ def search_user(string, session):
exact_match = session.query(User).filter(or_(User.name==string, User.card==string)).first()
if exact_match:
return exact_match
user_list = session.query(User).filter(or_(User.name.like('%'+string+'%'),User.card.like('%'+string+'%'))).all()
user_list = session.query(User).filter(or_(User.name.ilike('%'+string+'%'),
User.card.ilike('%'+string+'%'))).all()
return user_list
def search_product(string, session):
@ -15,8 +16,8 @@ def search_product(string, session):
if exact_match:
return exact_match
product_list = session.query(Product)\
.filter(or_(Product.bar_code.like('%'+string+'%'),
Product.name.like('%'+string+'%'))).all()
.filter(or_(Product.bar_code.ilike('%'+string+'%'),
Product.name.ilike('%'+string+'%'))).all()
return product_list
def guess_data_type(string):