Scala Slick 3.3.0和定制;def*”;投影
我正在使用slick 3.3.0和Scala 2.12.8,以及一个自定义的Scala Slick 3.3.0和定制;def*”;投影,scala,slick,Scala,Slick,我正在使用slick 3.3.0和Scala 2.12.8,以及一个自定义的def*方法,用于一个包含22个以上字段的case类。对于tuple:23,allowed:22,我仍然得到了太多的元素 我做错了什么 class DealerTable(tag: Tag) extends Table[Dealer](tag, "dealer") { import CustomConverters._ def id = column[Int]("id", O.PrimaryKey, O.Au
def*
方法,用于一个包含22个以上字段的case类。对于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)
class-DealerTable(tag:tag)扩展表[Dealer](tag,“Dealer”){
导入自定义转换器_
def id=列[Int](“id”,O.PrimaryKey,O.AutoInc)
def sellId=列[String](“sell_id”,O.Unique)
def customerId=列[Int](“客户id”,O.Unique)
def fake=列[Boolean](“fake”,O.Default(false))
def companyName=列[字符串](“公司名称”)
def district=列[字符串](“地区”)
def street=列[字符串](“街道”)
def postcode=列[字符串](“邮政编码”)
def city=列[字符串](“城市”)
def国家=列[国家](“国家”)
def firstName=列[字符串](“名字”)
def lastName=列[字符串](“姓氏”)
定义性别=列[选项[性别]](“性别”)
def email=列[字符串](“电子邮件”)
def phone=列[字符串](“电话”)
def mobilePhone=列[字符串](“移动电话”)
def SUBSCRIPTIONEDDATE=列[Option[LocalDate]](“订阅结束日期”)
def culture=列[culture](“culture”)
def额定值=列[浮动](“额定值”)
def minPrice=列[选项[Int]](“最小价格”)
def maxPrice=列[选项[Int]](“最高价格”)
def createdAt=列[ZonedDateTime](“创建时间”)
def updatedAt=列[ZonedDateTime](“更新时间”)
def*=
(
身份证件
塞利德,
客户ID,
伪造的
公司名称,
地区。?,
街道,
邮政编码
城市
国家,,
名字,
姓,
性别,,
电子邮件,
电话,
手机。?,
SubscriptionEndate,
文化
评级
明普莱斯,
maxPrice,
创建数据。?,
更新日期。?
)((Dealer.apply)已设置,Dealer.unapply)
}
最终案例类别经销商(id:Int,
sellId:String,
customerId:Int,
假:布尔值=假,
companyName:String,
地区:选项[字符串],
街道:弦,
邮编:String,
城市:字符串,
国家:国家,,
名字:String,
姓氏:String,
性别:选项[性别],
电子邮件:String,
电话:String,
手机电话:选项[字符串],
SubscriptionEndate:选项[LocalDate],
文化:文化,,
评级:期权[浮动],
minPrice:选项[Int],
maxPrice:选项[Int],
createdAt:Option[ZoneDateTime]=无,
updatedAt:选项[ZoneDateTime]=无)
Scala 2.12.8中没有超过22个元素的元组
这里是def*=
(
身份证件
sellId,…
您正在尝试创建这样的元组
谢谢你的回答,我理解。那么,用最少的样板代码和对映射的案例类(示例中的经销商)进行最少必要的修改来实现
def*
的最直接的方法是什么呢?您建议采用哪种方法?