Skip to content

Instantly share code, notes, and snippets.

@hamishdickson
Created January 31, 2015 15:40
Show Gist options
  • Save hamishdickson/62d5426cce7040cab07e to your computer and use it in GitHub Desktop.
Save hamishdickson/62d5426cce7040cab07e to your computer and use it in GitHub Desktop.
For some reason this doesn't work...
object DeleteExamples extends App with DatabaseExample {
InsertExamples.insertAll
val deleteStatement =
delete
.from(FruitTable)
.where(FruitTable.name === """Banana""")
// try again to run the delete statement in a transaction
database.withTransaction {
// running the delete statement returns the number of lines changed (ie deleted)
val numberInsert = deleteStatement.execute
println(numberInsert)
}
}
@brendanator
Copy link

Is banana in the fruit table?
The insertAll method runs this:

  lazy val insertStatement =
    insert
      .into(FruitTable)
      .columns(FruitTable.id, FruitTable.name, FruitTable.juiciness)
      .values(FruitTable.id -> 1, FruitTable.name -> "Watermelon", FruitTable.juiciness -> 10)
      .values(FruitTable.id -> 1, FruitTable.name -> "Tomato", FruitTable.juiciness -> 9)
      .values(FruitTable.id -> 1, FruitTable.name -> "Grape", FruitTable.juiciness -> 8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment