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

The current built-in > does not resolve its arguments #287

Open
andersmurphy opened this issue Oct 20, 2024 · 0 comments
Open

The current built-in > does not resolve its arguments #287

andersmurphy opened this issue Oct 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@andersmurphy
Copy link
Contributor

andersmurphy commented Oct 20, 2024

Openning this as an issue from our slack conversation.

I’m trying to filter for messages that have content longer than 200 characters:

       [?u :message/content ?content]
       [(> (count ?content) 200)]
       :find (count ?content).]
  @*conn*)
  
=> nil

Doesn’t return anything. Why? I’m assuming you can’t nest functions?

Separating out the functions still doesn’t return anything either though:

       [?u :message/content ?content]
       [(count ?content) ?n]
       [(> ?n 200)]
       :find (count ?content).]
       @*conn*)
=> nil    

If I implement my own greater than function this works:

  (> a b))

(d/q '[:where
       [?u :message/content ?content]
       [(count ?content) ?n]
       [(app.scratch/my2> ?n 200)]
       :find  (count ?content).]
       @*conn*)
=> 5       

Is this because > is special for range queries?

  • Anders

the current built-in > does not resolve its arguments. Remember, we cannot call eval, so we need to walk the arguments to >
resolve them.

  • Huahai

My take away from the conversation is the below should work, but nesting functions can't (as it gets messy with eval).

(d/q '[:where
       [?u :message/content ?content]
       [(count ?content) ?n]
       [(> ?n 200)]
       :find (count ?content).]
       @*conn*)
=> nil      

I'm going to have a look into this and see if I can create a PR.

@huahaiy huahaiy added the enhancement New feature or request label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants