jhc-systems / sqlest

Write SQL in Scala
https://jhc-systems.github.io/sqlest/latest/api/
Apache License 2.0
30 stars 17 forks source link

Update examples #5

Closed brendanator closed 9 years ago

brendanator commented 10 years ago

There is a large amount of functionality in sqlest that is not documented anywhere. The examples project needs to be expanded to show this functionality in action

hamishdickson commented 9 years ago

Is most of this functionality under test? If so I can clean some of that up into examples for documentation

brendanator commented 9 years ago

It is under test It would be great to turn it into some nice examples

hamishdickson commented 9 years ago

I'm having some issues getting delete to work - can you think why this delete example doesn't actually delete anything?

https://gist.github.com/hamishdickson/62d5426cce7040cab07e

hamishdickson commented 9 years ago

So I've had a quick debug and Database.execute delete does the following...

 def executeDelete(delete: Delete): Int = {
  checkInTransaction
  executeWithConnection { connection =>
    0
  }
}

which doesn't look to be doing a great deal.... am I missing something obvious?

Edit: I'm pretty sure it should look like this:

def executeDelete(delete: Delete): Int = {
  checkInTransaction
  executeWithConnection { connection =>
    val preparedStatement = statementBuilder(connection, delete)
    try {
      logger.debug(s"Executing delete")
      preparedStatement.executeUpdate
    } finally {
      try {
        if (preparedStatement != null) preparedStatement.close
      } catch {
        case e: SQLException =>
      }
    }
  }
}
hamishdickson commented 9 years ago

Examples of aggregate functions created in pull request #34