camelCase columns using auto generation

73 views
Skip to first unread message

Jeff Dyke

unread,
Jan 12, 2016, 3:19:25 PM1/12/16
to ScalikeJDBC Users Group
I have a database of camelCase columns and scalikejdbcGen will lower case the entire name.  Is there anyway to get them back into the objects as camelCase variable names so myColumnName rather than mycolumnname.

This works with my_column_name i realize, but was curious if you could have it basically not convert the columns at all, just leave them as they are in the DB, if they are already in camelCase, as are all my columns in this particular DB.

Thanks 

Jeff Dyke

unread,
Jan 12, 2016, 7:24:02 PM1/12/16
to ScalikeJDBC Users Group
Hi.  we hacked up the generation source to support this but its not supported on the way out without overriding every model with something like:

trait BLSQLSyntaxSupport[A] extends SQLSyntaxSupport[A] {
override val useSnakeCaseColumnName = false
}

object ClientTypesModel extends BLSQLSyntaxSupport[ClientTypesModel] {

Obviously you don't need this on every db file but every DAO/Model needs to extend it instead of SQLSyntaxSupport. Either jdbc or scalikejdbc is counting on this naming convention and in my mind i can either extend each model (editing after generation), or change my column names.  Is any support of camelCase columns desired in the future? 
(i like snake_case_columns for mysql).  If not i'm likely to change our DB structure since we are new and young.

Hopefully this will help someone else :)

Jeff

Tom

unread,
Sep 9, 2019, 5:07:51 PM9/9/19
to ScalikeJDBC Users Group
As of now, it looks like the source just has this formatting hard-coded, and I don't see `useSnakeCaseColumnName` used in the source generation anymore.

Maybe it would make sense to add a configuration flag to not auto format table and/or column names? (or, more ambitiously, perhaps support something that acts like a `sed` pipe?)
Reply all
Reply to author
Forward
0 new messages