I want that slick convert my "expression" into "sql query" but something is wrong!

141 views
Skip to first unread message

Reza Samee

unread,
Sep 23, 2014, 4:06:53 AM9/23/14
to scala...@googlegroups.com
Hello; I'm new in Slick ( and also in Scala ); When I tried Slick ( and some-other libs to select one to connect to rdbms ) I faced a problem via Slick's query generator; this is my code:

object SlickTest extends App{
   
   import scala.slick.driver.MySQLDriver.simple._
   
   class NumbersTable(tag:Tag)
     extends Table[(Int,Int)](tag:Tag,"numbers")
   {
     def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
     def number = column[Int]("number")
     def * = (id, number)
   }
   val numbers = TableQuery[NumbersTable]

   val db = Database.forURL(
        url="jdbc:mysql://host/db",
        user="?",
        password="?",
        driver="com.mysql.jdbc.Driver")

   db.withSession { implicit session =>
      val odds = for{
        r <- numbers
        if r.number % 2 == 1
      } yield r

      println(odds.selectStatement) // select s14.`id`, s14.`number` from `numbers` s14 where false

   }
}

Even I try it by collection ( without for-comp... ):
val odds = numbers.withFilter{ _.number % 2 == 1 } // select s14.`id`, s14.`number` from `numbers` s14 where false

What's the problem?
[ scala 2.11.2 | slick 2.1.0 | mysql 5.1.32 ]

Alec Zorab

unread,
Sep 23, 2014, 4:48:01 AM9/23/14
to scala...@googlegroups.com

Try "==="

--

---
You received this message because you are subscribed to the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/bf4dcda0-ba21-45b9-9c12-ed436875789f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reza Samee

unread,
Sep 23, 2014, 6:24:39 AM9/23/14
to scala...@googlegroups.com
Tanks; It seems that I msut first read entire documentation :)

--

---
You received this message because you are subscribed to a topic in the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scalaquery/VbpzLNjRBJQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/CAGv1iyJjJp9aUA%2B6oG09iDR7AbAOQQFah2UbeHJOJHwNQHNAXw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
رضا سامعی / http://samee.blog.ir
Reply all
Reply to author
Forward
0 new messages