I have a very simple MySQL table which represents a set of names using a single String column. I want to use Slick's insertOrUpdate
but it is generating incorrect MySQL, causing errors. Specifically, it wants to execute
insert into `TABLE1_NAME` (`column`) values ('value') on duplicate key update
It doesn't specify what to update, so this fails. A similar table with two columns upserts fine, with statements like
insert into `TABLE2_NAME` (`key`, `other_col`) values ('value1', 'value2') on duplicate key update `other_col`=VALUES(`other_col`)
Has anyone seen this? We do set a primary key for TABLE1
. We may be doing our table projection mapping incorrectly. We're using Slick 3.1.1.
class Table1(tag: Tag) extends Table[Table1Record](tag, "TABLE1_NAME") {
def value = column[String]("value", O.PrimaryKey, O.Length(254))
def * = (value) <> (Table1Record, Table1Record.unapply)
}
class Table2(tag: Tag) extends Table[Table2Record](tag, "TABLE2_NAME") {
def value1 = column[String]("value1", O.PrimaryKey, O.Length(254))
def value2 = column[String]("value2", O.Length(254))
def * = (value1, value2) <> (Table2Record.tupled, Table2Record.unapply)
}