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

String and UUID comparisons should work #281

Closed
dispalt opened this issue Mar 16, 2016 · 3 comments
Closed

String and UUID comparisons should work #281

dispalt opened this issue Mar 16, 2016 · 3 comments

Comments

@dispalt
Copy link

dispalt commented Mar 16, 2016

Version: 0.4.1
Module: quill-core

Expected behavior

Quill should support comparisons on two different scenarios. Basic string comparisons in the filter clause.

quote {
 (s:String) => q.filter(_.id > s)
}

And comparisons with UUID which doesn't by default support <, >, etc.

Actual behavior

String comparisons fail with being unable to parse the ast of the string comparisons. With UUID's there's no way to express the comparison.

Maybe you could add a special typeclass and parse that out for things that don't natively implement Ordering?

@getquill/maintainers

@dispalt
Copy link
Author

dispalt commented Mar 16, 2016

This is my workaround for UUID's,

  implicit class UUIDCompare(left: UUID) {
    def <(right: UUID) = quote(infix"$left < $right".as[Boolean])
    def >(right: UUID) = quote(infix"$left > $right".as[Boolean])
    def <=(right: UUID) = quote(infix"$left <= $right".as[Boolean])
    def >=(right: UUID) = quote(infix"$left >= $right".as[Boolean])
  }

@emanresusername
Copy link
Contributor

emanresusername commented May 30, 2016

👍 similarly for various Date/DateTime etc types

with this particular method with java.util.Date
with something like

db.run(quote{
query[Model].filter(_.expiresAt > lift(new Date()))
})

i get

[info]   java.util.NoSuchElementException: key not found: new java.util.Date()
[info]   at scala.collection.MapLike$class.default(MapLike.scala:228)
[info]   at scala.collection.AbstractMap.default(Map.scala:59)
[info]   at scala.collection.MapLike$class.apply(MapLike.scala:141)
[info]   at scala.collection.AbstractMap.apply(Map.scala:59)

@mxl
Copy link
Contributor

mxl commented Jul 9, 2017

Closed in favor of #677

@mxl mxl closed this as completed Jul 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants