光滑的3.3.0和自定义的“ def *”投影

时间:2019-03-19 13:50:29

标签: scala slick

我正在使用带有Scala 2.12.8的slick 3.3.0和自定义def *方法来处理具有22个以上字段的案例类。我仍然得到too many elements for tuple: 23, allowed: 22

我在做什么错了?

class DealerTable(tag: Tag) extends Table[Dealer](tag, "dealer") {

  import CustomConverters._

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

  def sellId = column[String]("sell_id", O.Unique)

  def customerId = column[Int]("customer_id", O.Unique)

  def fake = column[Boolean]("fake", O.Default(false))

  def companyName = column[String]("company_name")

  def district = column[String]("district")

  def street = column[String]("street")

  def postcode = column[String]("postcode")

  def city = column[String]("city")

  def country = column[Country]("country")

  def firstName = column[String]("first_name")

  def lastName = column[String]("last_name")

  def gender = column[Option[Gender]]("gender")

  def email = column[String]("email")

  def phone = column[String]("phone")

  def mobilePhone = column[String]("mobile_phone")

  def subscriptionEndDate = column[Option[LocalDate]]("subscription_end_date")

  def culture = column[Culture]("culture")

  def rating = column[Float]("rating")

  def minPrice = column[Option[Int]]("min_price")

  def maxPrice = column[Option[Int]]("max_price")

  def createdAt = column[ZonedDateTime]("created_at")

  def updatedAt = column[ZonedDateTime]("updated_at")

  def * =
    (
      id,
      sellId,
      customerId,
      fake,
      companyName,
      district.?,
      street,
      postcode,
      city,
      country,
      firstName,
      lastName,
      gender,
      email,
      phone,
      mobilePhone.?,
      subscriptionEndDate,
      culture,
      rating.?,
      minPrice,
      maxPrice,
      createdAt.?,
      updatedAt.?
    ) <> ((Dealer.apply _).tupled, Dealer.unapply)
}

final case class Dealer(id: Int,
                        sellId: String,
                        customerId: Int,
                        fake: Boolean = false,
                        companyName: String,
                        district: Option[String],
                        street: String,
                        postcode: String,
                        city: String,
                        country: Country,
                        firstName: String,
                        lastName: String,
                        gender: Option[Gender],
                        email: String,
                        phone: String,
                        mobilePhone: Option[String],
                        subscriptionEndDate: Option[LocalDate],
                        culture: Culture,
                        rating: Option[Float],
                        minPrice: Option[Int],
                        maxPrice: Option[Int],
                        createdAt: Option[ZonedDateTime] = None,
                        updatedAt: Option[ZonedDateTime] = None)

1 个答案:

答案 0 :(得分:1)

Scala 2.12.8中没有包含超过22个元素的元组。

这里std::find_if(V.begin(), V.end(), [&Name](type& V) {return Name == V->info.name;) 您正在尝试创建这样的元组。

22 Column limit for procedures

Slick - Update full object or more than 22 columns

https://lihaimei.wordpress.com/2016/03/30/slick-1-fix-more-than-22-columns-case/