Skip to content

Instantly share code, notes, and snippets.

@eishay
Created May 2, 2016 22:56
Show Gist options
  • Save eishay/895f3f34cba843701f96e97b7cf3ee7c to your computer and use it in GitHub Desktop.
Save eishay/895f3f34cba843701f96e97b7cf3ee7c to your computer and use it in GitHub Desktop.
trait DatabaseDialect[T <: DataBaseComponent] {
def day(date: DateTime): String
}
object MySqlDatabaseDialect extends DatabaseDialect[MySQL] {
def day(date: DateTime): String =
s"""STR_TO_DATE('${date.toStandardDateString}', '%Y-%m-%d')"""
}
object H2DatabaseDialect extends DatabaseDialect[H2] {
def day(date: DateTime): String =
s"""PARSEDATETIME('${date.toStandardDateString}', 'y-M-d')"""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment