[3.1] Slick Codegen - No matching shape found

302 views
Skip to first unread message

raul782

unread,
Apr 26, 2016, 11:05:48 AM4/26/16
to Slick / ScalaQuery
Hi, I'm using the slick codegen project with a customgenerator and it works fine, however when compiling I have this error across all my model tables :
From the error I see that my class CascoDetalle doesn't match the projection. 

[info] Loading project definition from /Users/raul/var/www/project
[info] Set current project to its-insurance (in build file:/Users/raul/var/www/project/)
[info] Compiling 3 Scala sources to /Users/raul/var/www/project/target/scala-2.11/classes...
[error] /Users/raul/var/www/project/src/main/scala/my/model/auto_generated/Default.scala:51: No matching Shape found.
[error] Slick does not know how to map the given types.
[error] Possible causes: T in Table[T] does not match your * projection. Or you use an unsupported type in a Query (e.g. scala List).
[error]   Required level: slick.lifted.FlatShapeLevel
[error]      Source type: (slick.lifted.Rep[Int], slick.lifted.Rep[Int], slick.lifted.Rep[java.time.LocalDateTime], slick.lifted.Rep[Option[java.time.LocalDateTime]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[java.time.LocalDate]], slick.lifted.Rep[Option[String]])
[error]    Unpacked type: (Int, Int, java.time.LocalDateTime, Option[java.time.LocalDateTime], Option[String], Option[String], Option[java.time.LocalDate], Option[String])
[error]      Packed type: Any
[error]     def * = (id, seccionCascosId, createdAt, updatedAt, nombreNave, matricula, fechaUltimaCarena, capitan) <> (CascosDetalle.tupled, CascosDetalle.unapply)
[error]                                                                                                            ^
[error] /Users/raul/var/www/project/src/main/scala/my/model/auto_generated/Default.scala:53: could not find implicit value for parameter od: slick.lifted.OptionLift[Default.this.driver.api.Rep[java.time.LocalDateTime],O]
[error]     def ? = (Rep.Some(id), Rep.Some(seccionCascosId), Rep.Some(createdAt), updatedAt, nombreNave, matricula, fechaUltimaCarena, capitan).shaped.<>({r=>import r._; _1.map(_=> CascosDetalle.tupled((_1.get, _2.get, _3.get, _4, _5, _6, _7, _8)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))
[error]                                                               ^
.......

And the relevant piece of code is the following :

package my.model.auto_generated

import slick.driver.MySQLDriver
import scala.concurrent.{Future, ExecutionContext}
//import play.api.db.slick.HasDatabaseConfig
import my.model._

//AUTO-GENERATED Slick data model

trait Default {

  val driver = MySQLDriver
 val profile = MySQLDriver
 import driver.api._

  import slick.model.ForeignKeyAction
 import slick.collection.heterogeneous._
 import slick.collection.heterogeneous.syntax._
 // NOTE: GetResult mappers for plain SQL are only generated for tables where Slick knows how to map the types of all columns.
 import slick.jdbc.{GetResult => GR}

  /** DDL for all tables. Call .create to execute. */
 lazy val schema: profile.SchemaDescription = Array(`my.cascosDetalles`.schema).reduceLeft(_ ++ _)
 @deprecated("Use .schema instead of .ddl", "3.0")
 def ddl = schema

  /** Entity class storing rows of table `itsInsurance.cascosDetalles`
  *  @param id Database column id SqlType(INT), PrimaryKey
  *  @param seccionCascosId Database column seccion_cascos_id SqlType(INT)
  *  @param createdAt Database column created_at SqlType(DATETIME)
  *  @param updatedAt Database column updated_at SqlType(DATETIME), Default(None)
  *  @param nombreNave Database column nombre_nave SqlType(VARCHAR), Length(200,true), Default(None)
  *  @param matricula Database column matricula SqlType(VARCHAR), Length(45,true), Default(None)
  *  @param fechaUltimaCarena Database column fecha_ultima_carena SqlType(DATE), Default(None)
  *  @param capitan Database column capitan SqlType(VARCHAR), Length(255,true), Default(None) */

  case class CascosDetalle(id: Int, seccionCascosId: Int, createdAt: java.time.LocalDateTime, updatedAt: Option[java.time.LocalDateTime] = None, nombreNave: Option[String] = None, matricula: Option[String] = None, fechaUltimaCarena: Option[java.time.LocalDate] = None, capitan: Option[String] = None)  {
   def asJs = my.model.auto_generated.SharedDefault.CascosDetalle(id, seccionCascosId, java.time.OffsetDateTime.of(createdAt, java.time.ZoneOffset.ofHours(1)).toEpochSecond, updatedAt.map(e => java.time.OffsetDateTime.of(e, java.time.ZoneOffset.ofHours(1)).toEpochSecond), nombreNave, matricula, fechaUltimaCarena, capitan)
 }
       
  /** GetResult implicit for fetching CascosDetalle objects using plain SQL queries */
 implicit def GetResultCascosDetalle(implicit e0: GR[Int], e1: GR[java.time.LocalDateTime], e2: GR[Option[java.time.LocalDateTime]], e3: GR[Option[String]], e4: GR[Option[java.time.LocalDate]]): GR[CascosDetalle] = GR{
   prs => import prs._
   val r = (<<[Int], <<[Int], <<[java.time.LocalDateTime], <<?[java.time.LocalDateTime], <<?[String], <<?[String], <<?[java.time.LocalDate], <<?[String])
   import r._
   CascosDetalle.tupled((_1, _2, _3, _4, _5, _6, _7, _8)) // putting AutoInc last
 }
 /** Table description of table cascos_detalle. Objects of this class serve as prototypes for rows in queries. */
  class CascosDetalleTable(_tableTag: Tag) extends Table[CascosDetalle](_tableTag, "cascos_detalle") {
   def * = (id, seccionCascosId, createdAt, updatedAt, nombreNave, matricula, fechaUltimaCarena, capitan) <> (CascosDetalle.tupled, CascosDetalle.unapply)
   /** Maps whole row to an option. Useful for outer joins. */
   def ? = (Rep.Some(id), Rep.Some(seccionCascosId), Rep.Some(createdAt), updatedAt, nombreNave, matricula, fechaUltimaCarena, capitan).shaped.<>({r=>import r._; _1.map(_=> CascosDetalle.tupled((_1.get, _2.get, _3.get, _4, _5, _6, _7, _8)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column id SqlType(INT), PrimaryKey */
   val id: Rep[Int] = column[Int]("id", O.PrimaryKey)
   /** Database column seccion_cascos_id SqlType(INT) */
   val seccionCascosId: Rep[Int] = column[Int]("seccion_cascos_id")
   /** Database column created_at SqlType(DATETIME) */
   val createdAt: Rep[java.time.LocalDateTime] = column[java.time.LocalDateTime]("created_at")
   /** Database column updated_at SqlType(DATETIME), Default(None) */
   val updatedAt: Rep[Option[java.time.LocalDateTime]] = column[Option[java.time.LocalDateTime]]("updated_at", O.Default(None))
   /** Database column nombre_nave SqlType(VARCHAR), Length(200,true), Default(None) */
   val nombreNave: Rep[Option[String]] = column[Option[String]]("nombre_nave", O.Length(200,varying=true), O.Default(None))
   /** Database column matricula SqlType(VARCHAR), Length(45,true), Default(None) */
   val matricula: Rep[Option[String]] = column[Option[String]]("matricula", O.Length(45,varying=true), O.Default(None))
   /** Database column fecha_ultima_carena SqlType(DATE), Default(None) */
   val fechaUltimaCarena: Rep[Option[java.time.LocalDate]] = column[Option[java.time.LocalDate]]("fecha_ultima_carena", O.Default(None))
   /** Database column capitan SqlType(VARCHAR), Length(255,true), Default(None) */
   val capitan: Rep[Option[String]] = column[Option[String]]("capitan", O.Length(255,varying=true), O.Default(None))

    /** Foreign key referencing `itsInsurance.polizaSeccionCascos` (database name FK_POLIZA_SECCION_CASCOS_ID_CASOS_DETALLE) */
   lazy val polizaSeccionCascosTableFk = foreignKey("FK_POLIZA_SECCION_CASCOS_ID_CASOS_DETALLE", seccionCascosId, `itsInsurance.polizaSeccionCascos`)(r => r.id, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
 }
 /** Collection-like TableQuery object for table `itsInsurance.cascosDetalles` */
 lazy val `itsInsurance.cascosDetalles` = new TableQuery(tag => new CascosDetalleTable(tag))
 }

Additionally, 
Intellij complains about this piece of code saying that cannot resolve the symbol _1, or=>import r._; _1.map

Thanks

raul782

unread,
Apr 29, 2016, 2:11:55 AM4/29/16
to Slick / ScalaQuery
Well the issue was that I didn't have the binder for Java8 Date classes in MySQL, I took an example from Postgres.
There is a PR being in the works (https://github.com/slick/slick/issues/1026) that will solve this problem for slick 3.2, in the meantime, I'm using the default date classes that the codegen uses.


On Tuesday, April 26, 2016 at 10:05:48 AM UTC-5, raul782 wrote:
Hi, I'm using the slick codegen project with a customgenerator and it works fine, however when compiling I have this error across all my model tables :
From the error I see that my class CascoDetalle doesn't match the projection. 

[info] Loading project definition from /Users/raul/var/www/project
[info] Set current project to its-insurance (in build file:/Users/raul/var/www/project/)
[info] Compiling 3 Scala sources to /Users/raul/var/www/project/target/scala-2.11/classes...
[error] /Users/raul/var/www/project/src/main/scala/my/model/auto_generated/Default.scala:51: No matching Shape found.
[error] Slick does not know how to map the given types.
[error] Possible causes: T in Table[T] does not match your * projection. Or you use an unsupported type in a Query (e.g. scala List).
[error]   Required level: slick.lifted.FlatShapeLevel
[error]      Source type: (slick.lifted.Rep[Int], slick.lifted.Rep[Int], slick.lifted.Rep[java.time.LocalDateTime], slick.lifted.Rep[Option[java.time.LocalDateTime]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[java.time.LocalDate]], slick.lifted.Rep[Option[String]])
[error]    Unpacked type: (Int, Int, java.time.LocalDateTime, Option[java.time.LocalDateTime], Option[String], Option[String], Option[java.time.LocalDate], Option[String])
[error]      Packed type: Any
[error]     def * = (id, seccionCascosId, createdAt, updatedAt, nombreNave, matricula, fechaUltimaCarena, capitan) <> (CascosDetalle.tupled, CascosDetalle.unapply)
[error]                                                                                                            ^
[error] /Users/raul/var/www/project/src/main/scala/my/model/auto_generated/Default.scala:53: could not find implicit value for parameter od: slick.lifted.OptionLift[Default.this.driver.api.Rep[java.
...
Reply all
Reply to author
Forward
0 new messages