I have problem when inserting into database. I use slick version 2.0.1-RC. I have used SourceCodeGenerator for generating source code. I have got this for table MAIN_TC_USER:
case class MainTcUserRow(id: Int, name: Option[String], surname: Option[String], username: Option[String], password: Option[String])
/** GetResult implicit for fetching MainTcUserRow objects using plain SQL queries */
implicit def GetResultMainTcUserRow(implicit e0: GR[Int], e1: GR[Option[String]]): GR[MainTcUserRow] = GR{
prs => import prs._
MainTcUserRow.tupled((<<[Int], <<?[String], <<?[String], <<?[String], <<?[String]))
}
/** Table description of table main_tc_user. Objects of this class serve as prototypes for rows in queries. */
class MainTcUser(tag: Tag) extends Table[MainTcUserRow](tag, "main_tc_user") {
def * = (id, name, surname, username, password) <> (MainTcUserRow.tupled, MainTcUserRow.unapply)
/** Maps whole row to an option. Useful for outer joins. */
def ? = (id.?, name, surname, username, password).shaped.<>({r=>import r._; _1.map(_=> MainTcUserRow.tupled((_1.get, _2, _3, _4, _5)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported."))
/** Database column id PrimaryKey */
val id: Column[Int] = column[Int]("id", O.PrimaryKey)
/** Database column name */
val name: Column[Option[String]] = column[Option[String]]("name")
/** Database column surname */
val surname: Column[Option[String]] = column[Option[String]]("surname")
/** Database column username */
val username: Column[Option[String]] = column[Option[String]]("username")
/** Database column password */
val password: Column[Option[String]] = column[Option[String]]("password")
}
/** Collection-like TableQuery object for table MainTcUser */
lazy val MainTcUser = new TableQuery(tag => new MainTcUser(tag))
I have tried to insert into MainTcUser table
new DBConnection(Tables.profile).connect.withSession{
implicit session =>
Tables.MainTcUser += user
}
or
new DBConnection(Tables.profile).connect.withSession{
implicit session =>
Tables.MainTcUser.map(s => s) += user
}
In both cases I've got error: Multiple markers at this line - value += is not a member of scala.slick.lifted.TableQuery[com.bsi.xpay.Tables.MainTcUser] - value += is not a member of scala.slick.lifted.TableQuery[com.bsi.xpay.Tables.MainTcUser]
Thanks for any help
You probably forgot to import .simple._
from you driver.
If that's not it also see Can't access delete method on Slick query which is related.