Slick 3.0.0 使用更新时出现警告
Slick 3.0.0 Warning when using Update
我有一个简单的更新,它尝试更新特定行的两列。这是我所做的:(我使用的是 Scala 2.11.7)
val update =
(id: Long, state: MyState) =>
myTable.filter(_.id === id)
.map(tbl =>(tbl.name, tbl.updateDate))
.update(state.name, DateTime.now(DateTimeZone.UTC))
这是我的编译器告诉我的:
[warn] /Users/joe/vpp-projects/app/my/project/services/database/MySchema.scala:40: Adapting argument list by creating a 2-tuple: this may not be what you want.
[warn] signature: UpdateActionExtensionMethodsImpl.update(value: T): JdbcActionComponent.this.DriverAction[Int,slick.dbio.NoStream,slick.dbio.Effect.Write]
[warn] given arguments: state.name, DateTime.now(DateTimeZone.UTC)
[warn] after adaptation: UpdateActionExtensionMethodsImpl.update((state.name, DateTime.now(DateTimeZone.UTC)): (String, org.joda.time.DateTime))
[warn] .update(state.name, DateTime.now(DateTimeZone.UTC))
[warn]
^
关于这里发生的事情有什么线索吗?我没有得到警告对我有任何用处,所以我可以摆脱它!
update
采用 Tuple
- scala 具有将具有多个参数的方法调用转换为元组的功能,如果没有采用多个参数的方法:
def anExample(value: (Int, Int, String)): Int = value._3.length
// This is how it is properly called
anExample((1, 2, "hi"))
// But this also works
anExample(1, 2, "hi")
您可以:
更新您的通话
// Note the added tuple parenthesis
.update((state.name, DateTime.now(DateTimeZone.UTC)))
将 -Yno-adapted-args
添加到您的 scalacOptions
以完全删除警告:
// If using SBT
scalacOptions in Compile += "-Yno-adapted-args"
我有一个简单的更新,它尝试更新特定行的两列。这是我所做的:(我使用的是 Scala 2.11.7)
val update =
(id: Long, state: MyState) =>
myTable.filter(_.id === id)
.map(tbl =>(tbl.name, tbl.updateDate))
.update(state.name, DateTime.now(DateTimeZone.UTC))
这是我的编译器告诉我的:
[warn] /Users/joe/vpp-projects/app/my/project/services/database/MySchema.scala:40: Adapting argument list by creating a 2-tuple: this may not be what you want.
[warn] signature: UpdateActionExtensionMethodsImpl.update(value: T): JdbcActionComponent.this.DriverAction[Int,slick.dbio.NoStream,slick.dbio.Effect.Write]
[warn] given arguments: state.name, DateTime.now(DateTimeZone.UTC)
[warn] after adaptation: UpdateActionExtensionMethodsImpl.update((state.name, DateTime.now(DateTimeZone.UTC)): (String, org.joda.time.DateTime))
[warn] .update(state.name, DateTime.now(DateTimeZone.UTC))
[warn]
^
关于这里发生的事情有什么线索吗?我没有得到警告对我有任何用处,所以我可以摆脱它!
update
采用 Tuple
- scala 具有将具有多个参数的方法调用转换为元组的功能,如果没有采用多个参数的方法:
def anExample(value: (Int, Int, String)): Int = value._3.length
// This is how it is properly called
anExample((1, 2, "hi"))
// But this also works
anExample(1, 2, "hi")
您可以:
更新您的通话
// Note the added tuple parenthesis .update((state.name, DateTime.now(DateTimeZone.UTC)))
将
-Yno-adapted-args
添加到您的scalacOptions
以完全删除警告:// If using SBT scalacOptions in Compile += "-Yno-adapted-args"