We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Let's say we have a table that looks like this:
CREATE TABLE media ( id SERIAL PRIMARY KEY, title text, artist text, album text );
And want to create a query that sometimes searches the fields title, artist, and album. So one query might look like:
SELECT * FROM media WHERE title LIKE "%someTitle%";
But others might look like:
SELECT * FROM media WHERE title LIKE "%someTitle%" AND album LIKE "%someAlbum%";
The way I figure out was to use ScalarExpr:INJECT like so:
ScalarExpr:INJECT
;; make-media-single-condition: (list/c symbol? string?) -> scalar-expr-ast? (define (make-media-single-condition condition) (match-let ([(list col val) condition]) (scalar-expr-qq (like (Ident:AST ,(make-ident-ast col)) (|| "%" (ScalarExpr:AST ,val) "%"))))) (scalar-expr-qq (ScalarExpr:INJECT ,(string-join (map (compose sql-ast->string make-media-single-condition) conditions) " AND ")))])))
Which is a bit hacky but gets the job done. Is there a way to apply the list of ScalarExpr to the and?
apply
ScalarExpr
and
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Let's say we have a table that looks like this:
And want to create a query that sometimes searches the fields title, artist, and album. So one query might look like:
But others might look like:
The way I figure out was to use
ScalarExpr:INJECT
like so:Which is a bit hacky but gets the job done. Is there a way to
apply
the list ofScalarExpr
to theand
?The text was updated successfully, but these errors were encountered: