Created
May 17, 2013 15:19
-
-
Save debasishg/5599764 to your computer and use it in GitHub Desktop.
Problem with Slick generating sql for count with hsqldb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // sample query using count | |
| val c = | |
| for { | |
| d <- Databases if (d.name like s"$name%") && (d.hasDistinctCount === true) | |
| } yield t.count | |
| println(c.selectStatement) | |
| // generates this sql for h2 | |
| select select count(1) from "Databases" x2 where (x2."name" like 'world%') and (x2."hasDistinctCount" = true) | |
| // generates this incorrect statement for hsqldb | |
| select select count(1) from (VALUES (0)) from "Databases" x2 where (x2."name" like cast('world%' as varchar(16777216))) and (x2."hasDistinctCount" = true) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I change the query to
then I get following statement
select count(x2."name") from "Databases" x2 where (x2."name" like cast('world%' as varchar(16777216))) and (x2."hasDistinctCount" = true)
which is syntactically correct. But the "like" query doesn't work properly. If there r 2 records with name = "world1" and "world2", the select returns a count of 1.