scala.slick.SlickException: Cannot use node Select id for inserting data

1,274 views
Skip to first unread message

John Ky

unread,
Feb 11, 2014, 9:41:46 AM2/11/14
to scala...@googlegroups.com
Hi Slick users,

I've upgraded my code to slick 2.0.0 and now I get this exception:

scala.slick.SlickException: Cannot use node Select id for inserting data

id is defined as:

def id                      = column[Long]  ("id", O.PrimaryKey, O.AutoInc)

The insert method I wrote looks like:

  def insert(row: Row)(implicit session: Session): Unit = {
    baseTableRow.all.shaped.insert(
      ( row.id
      , row.a
      , row.b
      , row.c
      , row.d
      , row.e
      , row.f
      , row.g
      , row.h
      , ( row.i.gross, row.i.tax )
      , ( row.j.gross, row.j.tax )
      , ( row.k.gross, row.k.tax )
      , ( row.l.gross, row.l.tax )
      , ( row.m.gross, row.m.tax )
      , ( row.n.gross, row.n.tax )
      , ( row.o.gross, row.o.tax )
      , ( row.p.gross, row.p.tax )
      , ( row.q.gross, row.q.tax )
      , ( row.r.gross, row.r.tax )))
  }

This was a work around that used nested case classes to work around 22 tuple limitations (which worked for slick 1.0.0).  Not sure if that is relevant.

Am I missing something?

Cheers,

-John

scala.slick.SlickException: Cannot use node Select id for inserting data
at scala.slick.compiler.InsertCompiler$$anonfun$apply$1.scala$slick$compiler$InsertCompiler$class$$anonfun$$tr$1(InsertCompiler.scala:48)
at scala.slick.compiler.InsertCompiler$$anonfun$apply$1$$anonfun$scala$slick$compiler$InsertCompiler$class$$anonfun$$tr$1$2.apply(InsertCompiler.scala:35)
at scala.slick.compiler.InsertCompiler$$anonfun$apply$1$$anonfun$scala$slick$compiler$InsertCompiler$class$$anonfun$$tr$1$2.apply(InsertCompiler.scala:35)
at scala.slick.ast.Util$$anonfun$mapOrNone$1.apply(Util.scala:15)
at scala.slick.ast.Util$$anonfun$mapOrNone$1.apply(Util.scala:14)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at scala.slick.ast.Util$.mapOrNone(Util.scala:14)
at scala.slick.ast.Node$class.nodeMapChildren(Node.scala:42)
at scala.slick.ast.ProductNode$$anon$2.nodeMapChildren(Node.scala:151)
at scala.slick.compiler.InsertCompiler$$anonfun$apply$1.scala$slick$compiler$InsertCompiler$class$$anonfun$$tr$1(InsertCompiler.scala:35)
at scala.slick.compiler.InsertCompiler$$anonfun$apply$1.apply(InsertCompiler.scala:50)
at scala.slick.compiler.InsertCompiler$$anonfun$apply$1.apply(InsertCompiler.scala:17)
at scala.slick.compiler.CompilerState.map(QueryCompiler.scala:144)
at scala.slick.compiler.InsertCompiler$class.apply(InsertCompiler.scala:17)
at scala.slick.jdbc.JdbcMappingCompilerComponent$JdbcInsertCompiler.apply(JdbcMappingCompilerComponent.scala:49)
at scala.slick.compiler.QueryCompiler$$anonfun$runPhase$1.apply(QueryCompiler.scala:55)
at scala.slick.compiler.QueryCompiler$$anonfun$runPhase$1.apply(QueryCompiler.scala:54)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
at scala.slick.ast.SymbolNamer.use(Symbol.scala:101)
at scala.slick.compiler.QueryCompiler.runPhase(QueryCompiler.scala:54)
at scala.slick.compiler.QueryCompiler$$anonfun$run$2.apply(QueryCompiler.scala:46)
at scala.slick.compiler.QueryCompiler$$anonfun$run$2.apply(QueryCompiler.scala:46)
at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:144)
at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:144)
at scala.collection.Iterator$class.foreach(Iterator.scala:727)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableOnce$class.foldLeft(TraversableOnce.scala:144)
at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:105)
at scala.slick.compiler.QueryCompiler.run(QueryCompiler.scala:46)
at scala.slick.compiler.QueryCompiler.run(QueryCompiler.scala:41)
at scala.slick.profile.BasicProfile$Implicits$class.shapedValueToInsertInvoker(BasicProfile.scala:52)
at scala.slick.driver.JdbcProfile$$anon$1.shapedValueToInsertInvoker(JdbcProfile.scala:25)
at com.lib.taximate.slick.table.JobFares$.insert(JobFares.scala:137)
at com.lib.taximate.slick.impl.JobFareModuleImpl$$anonfun$insertFare$1.apply(JobFareModuleImpl.scala:18)
at com.lib.taximate.slick.impl.JobFareModuleImpl$$anonfun$insertFare$1.apply(JobFareModuleImpl.scala:18)
at scala.slick.backend.DatabaseComponent$DatabaseDef$class.withSession(DatabaseComponent.scala:31)
at scala.slick.jdbc.JdbcBackend$DatabaseFactoryDef$$anon$3.withSession(JdbcBackend.scala:46)
at com.lib.taximate.db.TaximateSlickDbModule$$anonfun$inTaximateSlick$1.apply(TaximateSlickDbModule.scala:15)
at com.lib.taximate.db.TaximateSlickDbModule$$anonfun$inTaximateSlick$1.apply(TaximateSlickDbModule.scala:15)
at scalaz.KleisliFunctions$$anon$17.run(Kleisli.scala:160)
at com.go.base.db.RunDbModuleImpl$class.unsafeTransaction(RunDbModuleImpl.scala:4)
at com.gocatch.gcs2.Main$.com$gocatch$gcs2$db$SquerylRunDbModuleOverlay$$super$unsafeTransaction(Main.scala:80)
at com.gocatch.gcs2.db.SquerylRunDbModuleOverlay$$anonfun$unsafeTransaction$1.apply(SquerylRunDbModuleOverlay.scala:11)
at com.gocatch.gcs2.db.SquerylRunDbModuleOverlay$$anonfun$unsafeTransaction$1.apply(SquerylRunDbModuleOverlay.scala:11)
at org.squeryl.dsl.QueryDsl$class._using(QueryDsl.scala:46)
at org.squeryl.dsl.QueryDsl$class._executeTransactionWithin(QueryDsl.scala:115)
at org.squeryl.dsl.QueryDsl$class.transaction(QueryDsl.scala:69)
at org.squeryl.PrimitiveTypeMode$.transaction(PrimitiveTypeMode.scala:40)
at com.gocatch.gcs2.db.SquerylRunDbModuleOverlay$class.unsafeTransaction(SquerylRunDbModuleOverlay.scala:11)
at com.gocatch.gcs2.Main$.unsafeTransaction(Main.scala:80)
at com.gocatch.gcs2.unsafe.RunDbModuleProxy$class.unsafeTransaction(RunDbModuleProxy.scala:11)
at com.gocatch.gcs2.job.Hail$.unsafeTransaction(Hail.scala:864)
at com.gocatch.gcs2.job.Hail$$anonfun$serializeToNewJob$1.apply$mcJ$sp(Hail.scala:1081)
at com.gocatch.gcs2.job.Hail$$anonfun$serializeToNewJob$1.apply(Hail.scala:1041)
at com.gocatch.gcs2.job.Hail$$anonfun$serializeToNewJob$1.apply(Hail.scala:1041)
at org.squeryl.dsl.QueryDsl$class._using(QueryDsl.scala:46)
at org.squeryl.dsl.QueryDsl$class._executeTransactionWithin(QueryDsl.scala:115)
at org.squeryl.dsl.QueryDsl$class.transaction(QueryDsl.scala:78)
at org.squeryl.PrimitiveTypeMode$.transaction(PrimitiveTypeMode.scala:40)
at com.gocatch.gcs2.job.Hail$.serializeToNewJob(Hail.scala:1041)
at com.gocatch.gcs2.actors.JobWorker$$anonfun$receive$1.applyOrElse(JobWorker.scala:116)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425)
at akka.actor.ActorCell.invoke(ActorCell.scala:386)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230)
at akka.dispatch.Mailbox.run(Mailbox.scala:212)
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:502)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Stefan Zeiger

unread,
Feb 11, 2014, 9:51:09 AM2/11/14
to scala...@googlegroups.com
On 2014-02-11 15:41, John Ky wrote:
Hi Slick users,

I've upgraded my code to slick 2.0.0 and now I get this exception:

scala.slick.SlickException: Cannot use node Select id for inserting data

id is defined as:

def id                      = column[Long]  ("id", O.PrimaryKey, O.AutoInc)

The insert method I wrote looks like:

  def insert(row: Row)(implicit session: Session): Unit = {
    baseTableRow.all.shaped.insert(

What are baseTableRow and baseTableRow.all?

--
Stefan Zeiger
Slick Tech Lead
Typesafe - Build Reactive Apps!
Twitter: @StefanZeiger

John Ky

unread,
Feb 11, 2014, 4:08:59 PM2/11/14
to scala...@googlegroups.com
Hi Stefan,

Here's what i have.

Cheers,

-John

class RowTable(tag: Tag) extends Table[Long](tag, "Rows") {
  def id = column[Long]  ("id", O.PrimaryKey, O.AutoInc)

  def a = column[Long]  ("a")
  def b = column[Long]  ("b")
  def c = column[Int]   ("c")
  def d = column[Int]   ("d")
  def e = column[Int]   ("e")
  def f = column[Int]   ("f")
  def g = column[Int]   ("g")
  def h = column[Int]   ("h")

  def i = column[Int]   ("i")
  def j = column[Int]   ("j")
  def k = column[Int]   ("k")
  def l = column[Int]   ("l")
  def m = column[Int]   ("m")
  def n = column[Int]   ("n")
  def o = column[Int]   ("o")
  def p = column[Int]   ("p")
  def q = column[Int]   ("q")
  def r = column[Int]   ("r")

  def igst = column[Int]   ("igst")
  def jgst = column[Int]   ("jgst")
  def kgst = column[Int]   ("kgst")
  def lgst = column[Int]   ("lgst")
  def mgst = column[Int]   ("mgst")
  def ngst = column[Int]   ("ngst")
  def ogst = column[Int]   ("ogst")
  def pgst = column[Int]   ("pgst")
  def qgst = column[Int]   ("qgst")
  def rgst = column[Int]   ("rgst")

  def * = id

  def all =
      ( id
      , a
      , b
      , c
      , d
      , e
      , f
      , g
      , h
      , ( i, igst )
      , ( j, jgst )
      , ( k, kgst )
      , ( l, lgst )
      , ( m, mgst )
      , ( n, ngst )
      , ( o, ogst )
      , ( p, pgst )
      , ( q, qgst )
      , ( r, rgst )

Stefan Zeiger

unread,
Feb 12, 2014, 6:12:15 AM2/12/14
to scala...@googlegroups.com
I don't see a definition for baseTableRow, so I'm assuming it is the TableQuery's baseTableRow. Note the scaladoc comment:

  /** Get the "raw" table row that represents the table itself, as opposed to
    * a Path for a variable of the table's type. This method should generally
    * not be called from user code. */
  def baseTableRow: E = unpackable.value

Whatever it really is, it's the wrong thing if you can call baseTableRow.all.insert You need something like myTable.map(_.all).insert
--
 
---
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/d98f5646-d7ae-4b03-b1a1-92f99e97ed37%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Naftoli Gugenheim

unread,
Feb 13, 2014, 3:30:39 AM2/13/14
to scala...@googlegroups.com

Perhaps try
tableQuery.map(_.all).forceInsert((row.id, ...))

Assuming you want to specify the id and not rely on the auto-increment.

--
 
---
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.
Reply all
Reply to author
Forward
0 new messages