Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why cannot use compiled Insert statement in Slick

Tags:

sql

slick

Slick experts

I'm learning and playing with Slick, and I have question: the document says the Compiled Query only works for select, update and delete, http://slick.typesafe.com/doc/2.0.0/queries.html#compiled-queries

I'm curious why it does not support insert? Does it mean everytime I have to insert a row in the table, the statement needs to be re-compiled by Slick? Is there any way to compile an insert statement? Thanks!

like image 820
Terry Tao Avatar asked Jan 29 '14 04:01

Terry Tao


1 Answers

The documentation should be clearer here. For inserts you would cache the insert invoker instead.

val i = someQuery.insertInvoker
i.insert( foo )
i.insert( bar )

The query is only compiled once.

I created a pull request to improve our documentation on this point: https://github.com/slick/slick/pull/629

like image 140
cvogt Avatar answered Nov 22 '22 02:11

cvogt