Question

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

Was it helpful?

Solution

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.

OTHER TIPS

You can override dbTableName in your MetaMapper

object ModelClass extends ModelClass with LongKeyedMetaMapper {
    override def dbTableName = "model_class"
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top