DoubleTypedField does not work with optional_? = false

11 views
Skip to first unread message

Jens Haase

unread,
Oct 21, 2011, 5:03:23 PM10/21/11
to Lift
Hey everybody,

I think there is a little bug in the class DoubleTypedField (Record).
The setFromString method does not handle the empty string when the
field is optional. I should look like this:

def setFromString(s: String): Box[Double] = s match {
case "" if optional_? => setBox(Empty)
case _ =>setBox(tryo(java.lang.Double.parseDouble(s)))
}

Hope, that is correct.

Alexandre Martins

unread,
Jan 9, 2012, 11:50:10 PM1/9/12
to lif...@googlegroups.com
Hello

Just bumped into exactly the same problem. And while checking the source I found that this bug exists in some Record implementation of a numeric field while in others it is already corrected.

Fields with the bug:
 - DoubleTypedField
 - DecimalTypedField
 - LongTypedField

Fields without the bug:
 - BinaryTypedField
 - DateTimeTypedField
 - IntTypedField

EmailTypedField might also have a similar bug (I think) since the validateEmail() doesn't include the empty string as valid when the field is empty.

Was this bug reported somewhere (by Jens Haase for example) or should I do it? 


--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
-end-
Alexandre Martins
PhD student at:
- Centre for Neuroscience and Cell Biology
http://cnbc.pt/
- Centre for Informatics and Systems of the University of Coimbra
http://cisucpt.dei.uc.pt/

David Whittaker

unread,
Jan 10, 2012, 12:06:13 PM1/10/12
to lif...@googlegroups.com
Alexandre,

I don't see any open tickets referencing the issue.  You can create one and assign it to me.

Alexandre Martins

unread,
Jan 10, 2012, 1:34:05 PM1/10/12
to lif...@googlegroups.com
Done.

Alexandre
Reply all
Reply to author
Forward
0 new messages