Liftweb mapper - lowercase configuration table name

Is it possible to forcibly use the lowerweb transfer table name for model queries?

+3
source share
2 answers

If you need a single way to generate table and column names, you must install MapperRules. {tableName, columnName} PartialFunctions. So, if you want all your tables and columns to be serpentine, include the following two lines in the Boot.scala file:

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

This avoids the extraneous dbTableName name redefinition pattern for each class.

+4
source

You can override dbTableName name in MetaMapper

object ModelClass extends ModelClass with LongKeyedMetaMapper {
    override def dbTableName = "model_class"
}
+7
source

Source: https://habr.com/ru/post/1759280/


All Articles