*** Potential breaking change *** : MappedField.name, affects Mapper <> JSON

1 view
Skip to first unread message

Jeppe Nejsum Madsen

unread,
Feb 18, 2010, 7:13:36 AM2/18/10
to lift-a...@googlegroups.com
---------- Forwarded message ----------
From: Jeppe Nejsum Madsen <je...@ingolfs.dk>
Date: Thu, Feb 18, 2010 at 12:22 PM
Subject: Potential breaking change: MappedField.name, affects Mapper <> JSON
To: lif...@googlegroups.com


Hi,

As part of fixing
https://www.assembla.com/spaces/liftweb/tickets/155-lift-mapper-%28record%29-camelcase-to-snake_case-for-case-insensitive-databases
, I would like to change the semantics of MappedField.name slightly:

Currently, the name is always lowercased, ie:

class SampleModel extends KeyedMapper[Long, SampleModel] {
 object id extends MappedLongIndex(this)
 object firstName extends MappedString(this, 32)
 object moose extends MappedNullableLong(this)
 object notNull extends MappedString(this, 32)
}

firstName.name == "firstname" && notNull.name == "notnull" && id.name=="id"

I would like to have name preserve the case of the field such that:

firstName.name == "firstName" && notNull.name == "notNull" && id.name=="id"

Reasons:

1) More consistent. css styles, default column headers etc based on
name now follows the actual
  field name
2) Easier to implement #155 :-)

name is used when serializing a Mapped object as JSON. So the JSON
representation will be changed (unless we lowercase the name only when
creating JSON, but this goes against 1)

Now:
{
 "$persisted":true,
 "id":1,
 "firstname":"Elwood",
 "moose":null,
 "notnull":""
}

After proposed change:
{
 "$persisted":true,
 "id":1,
 "firstName":"Elwood",
 "moose":null,
 "notNull":""
}

I would like to get a feel for the pain this will cause people....

/Jeppe

Reply all
Reply to author
Forward
0 new messages