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

How could I use high order func in my query? #190

Open
ArtZoick opened this issue Mar 25, 2022 · 1 comment
Open

How could I use high order func in my query? #190

ArtZoick opened this issue Mar 25, 2022 · 1 comment

Comments

@ArtZoick
Copy link

I want to initiate a query using higher-order functions with the following sql, but I can't find the usage method in the document, how to use this query?
select * from test_table where arrayExists(x -> x LIKE '192.168.1.1%',host_list)=1

@sswest
Copy link

sswest commented Aug 11, 2022

Since ORM will escape strings, you cannot directly pass the higher-order function string type to F, but you can easily customize a class and implement the str method, such as

class Lambda:
    def __init__(self, symbol: str):
        self.symbol = symbol

    def __str__(self):
        return self.symbol

F("arrayExists", Lambda("x -> x LIKE '192.168.1.1%'"), host_list)

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

2 participants