8 lines
266 B
Python
8 lines
266 B
Python
from sqlalchemy.orm import InstrumentedAttribute
|
|
from sqlalchemy import ColumnElement
|
|
|
|
|
|
def fuzzy_match(attr: InstrumentedAttribute[str], q: str) -> ColumnElement:
|
|
q_list = q.split()
|
|
qq = "%" + "%".join(q_list) + "%"
|
|
return attr.ilike(f"%{qq.lower()}%")
|