显示方法的参数过多
Shows too many arguments for method
我试图在 apple_reportDB
中插入一些数据,但我得到的错误是 Too many arguments for method in the insert query
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")
}
您的 Suppliers
table 扩展 Table[AppleReport]
。因此,您的插入语句需要一个 case class AppleReport
的对象。
但是您使用 3 个字符串 ("apple","cow","cat")
调用该方法,因此出现错误。将其更改为 AppleReport("apple","cow","cat")
,您的代码将起作用
我试图在 apple_reportDB
中插入一些数据,但我得到的错误是 Too many arguments for method in the insert query
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")
}
您的 Suppliers
table 扩展 Table[AppleReport]
。因此,您的插入语句需要一个 case class AppleReport
的对象。
但是您使用 3 个字符串 ("apple","cow","cat")
调用该方法,因此出现错误。将其更改为 AppleReport("apple","cow","cat")
,您的代码将起作用