Skip to content
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

Fuzzy query is not working #4

Open
zengsihang opened this issue May 4, 2023 · 0 comments
Open

Fuzzy query is not working #4

zengsihang opened this issue May 4, 2023 · 0 comments

Comments

@zengsihang
Copy link

The fuzzy query in the pip documentation is not working. Changing a little bit to the Manager class (change "==" in the query function to "ilike") solves this problem.

class BetterManager(Manager):
    def __init__(self, dbfile, logger=None):
        super().__init__(dbfile, logger)

    def fuzzy_query(self, Meta, key=None, value=None):
        query = self.session.query(Meta)
        if key:
            if key not in Meta.__dict__:
                self.logger.warning(f'unavailable key: {key}')
                return None
            else:
                query = query.filter(Meta.__dict__[key].ilike(value))
        return query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant