Scala 为方法显示太多参数

Scala 为方法显示太多参数,scala,slick-2.0,Scala,Slick 2.0,我试图在apple\u reportDB中插入少量数据,但由于插入查询中方法的参数太多而导致错误 import scala.slick.driver.MysqlDriver.simple._ case class AppleReport(quantity:String,price:String,sale_amount:String) //tables class Suppliers(tag: Tag) extends Table[AppleReport](tag, "apple_re

我试图在
apple\u reportDB
中插入少量数据,但由于插入查询中方法的
参数太多而导致错误

import scala.slick.driver.MysqlDriver.simple._

case class AppleReport(quantity:String,price:String,sale_amount:String)  

//tables
class Suppliers(tag: Tag)
  extends Table[AppleReport](tag, "apple_report") {

def quantity=column[String]("quantity")
def price=column[String]("price")
def sale_amount=column[String]("sale_amount")

def * =(quantity,price,sale_amount) <> (AffiliateReportFields.tupled,AffiliateReportFields.unapply)
}

   //declaring interface
val suppliers: TableQuery[Suppliers] = TableQuery[Suppliers]

val db=Database.forURL("jdbc:mysql://localhost:3306/apple_reportDB","root","",null, driver="com.mysql.jdbc.Driver")
  db.withSession { implicit session =>

//create table
suppliers.ddl.create
//Insert data
suppliers += ("apple","cow","cat")

  }
导入scala.slick.driver.MysqlDriver.simple_
案例类AppleReport(数量:字符串、价格:字符串、销售金额:字符串)
//桌子
类别供应商(标签:标签)
扩展表[AppleReport](标记,“苹果报告”){
定义数量=列[字符串](“数量”)
def price=列[字符串](“价格”)
def销售金额=列[字符串](“销售金额”)
def*=(数量、价格、销售金额)(AffiliaterReportFields.tupped,AffiliaterReportFields.unapply)
}
//声明接口
val供应商:TableQuery[供应商]=TableQuery[供应商]
val db=Database.forURL(“jdbc:mysql://localhost:3306/apple_reportDB“,”根“,”,null,driver=“com.mysql.jdbc.driver”)
db.with会话{隐式会话=>
//创建表
suppliers.ddl.create
//插入数据
供应商+=(“苹果”、“奶牛”、“猫”)
}

您的
供应商
表扩展了
表[AppleReport]
。因此,insert语句需要一个case class
AppleReport
的对象

但是,您使用3个字符串调用该方法
(“apple”、“cow”、“cat”)
,因此会出现错误。将其更改为
AppleReport(“apple”、“cow”、“cat”)
您的代码将正常工作