tags:

views:

71

answers:

2

Is it possible to force liftweb mapper use table name in lower case for querying models?

+3  A: 

You can override dbTableName in your MetaMapper

object ModelClass extends ModelClass with LongKeyedMetaMapper {
    override def dbTableName = "model_class"
}
jgoday
+2  A: 

If you want a uniform way of generating your table and column names, you should set the MapperRules.{tableName,columnName} PartialFunctions. So, if you want all of your tables and columns to be snake case, include the following two lines in your Boot.scala file:

MapperRules.tableName = (_, name) => StringHelpers.snakify(name)
MapperRules.columnName = (_, name) => StringHelpers.snakify(name)

This avoids the extraneous boilerplate of overriding the dbTableName on each class.

Aaron
Excellent answer.
David Pollak