Controlling Schemifier naming conventions with MapperRules
June 27th, 2010
I was recently asked how to stop Lift’s Mapper from flattening the naming of columns during its “schemification” process. Well, there is a little known configuration object in the net.liftweb.mapper package called MapperRules.
MapperRules contains a whole bunch of stuff that you can use to control the way that Mapper names stuff that it creates and how it will try and inspect your database. If you prefer (like me) to have columns and tables like first_name rather than firstname, then add the following to Boot.scala:
class Boot {
def boot {
...
MapperRules.tableName = (_,name) => StringHelpers.snakify(name)
MapperRules.columnName = (_,name) => StringHelpers.snakify(name)
...
}
}
Thats it!
Lift In Action - The comprehensive guide to Lift
June 23rd, 2010
So I have been pretty lax of late with keeping this blog up to date. There is a very good reason for that, and that is I am currently working on a book about Lift – If you haven’t heard, Lift In Action will be available on Manning Publications in Q1 of 2011 and is currently available as an eBook via the Manning website. Its generally eating a lot of my time right now so I haven’t had a chance to post about all the cool new stuff that is making its way into Lift every week – hopefully I will soon get time to write about the awesome new Record persistence system that we are all very excited about as we are currently integrating the extremely awesome Squeryl as a backend for dealing with RDBMS.
By all means, go and checkout the book and let me know what you think as it develops in the author online forums and I will get back to you ASAP. Enjoy!
