slick-pg icon indicating copy to clipboard operation
slick-pg copied to clipboard

any operator must be on right-hand-side of comparison operator

Open timcharper opened this issue 10 years ago • 3 comments

I don't know if there is a way to warn about this, but the following are not the same:

eventId.asColumnOf[String] === s.eventIds.any

and

s.eventIds.any === eventId.asColumnOf[String]

The latter will be rejected by Postgres.

It may be outside of the bounds of what is possible with slick, but ideally the compiler should throw a warning when the latter is encountered. (Perhaps you could define === on the return result of .any, such that using it issues a warning / refuses to compile).

timcharper avatar Aug 17 '15 23:08 timcharper

I'm afraid we can't resolve it. You know, the return result of .any is a normal Rep[T] instead of a Rep[Array[T]], so we can't find out a way to tell the compiler to use our defined ===.

tminglei avatar Aug 19 '15 13:08 tminglei

I know; yes.

I'm wondering if it would be better to not define .any, and instead create a function which accepts two Rep's. Implicit proofs could be used then to verify that the comparison will work.

I'll tinker and send a patch with the idea.

Sent from my iPhone

On Aug 19, 2015, at 07:51, 涂名雷 [email protected] wrote:

I'm afraid we can't resolve it. You know, the return result of .any is a normal Rep[T] instead of a Rep[Array[T]], so we can't find out a way to tell the compiler to use our defined ===.

— Reply to this email directly or view it on GitHub.

timcharper avatar Aug 19 '15 18:08 timcharper

Are you going to define an .anyEquals method, which accept a Rep[_] parameter?

If that's right, how about >, <, >=, <=, <> ?

tminglei avatar Aug 19 '15 23:08 tminglei