Some Record fields don't work when optional_? = false
Based on the thread https://groups.google.com/d/msg/liftweb/jo3xkhu2Fjs/lKV4Cdzgy9EJ
There is a bug in some Record field classes by which the setFromString method does not handle the empty string when the
field is optional.
Fields with the bug:
Fields without the bug (if it's not here, I didn't check it):
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.
To correct this bug the following (or equivalent) code can be used:
There is a bug in some Record field classes by which the setFromString method does not handle the empty string when the
field is optional.
Fields with the bug:
- DoubleTypedField
- DecimalTypedField
- LongTypedField
- BooleanTypedField
Fields without the bug (if it's not here, I didn't check it):
- 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.
To correct this bug the following (or equivalent) code can be used:
def setFromString(s: String): Box[Double] = s match {
case "" if optional_? => setBox(Empty)
case _ =>setBox(tryo(java.lang.Double.parseDouble(s)))
}
Leave a comment
on 2012-01-10 18:30 *
By Alexandre Martins
Description changed from Based on the thread https:/... to Based on the thread https:/...
Summary changed from DoubleTypedField does not work with optional_? = false to Some Record fields don't work when optional_? = false
on 2012-01-10 18:33 *
By dpp
Type set to Defect
Assigned to changed from dpp to David Whittaker
Component changed from None to Record
Pointed to David W
on 2013-01-22 15:07 *
By Alexandre Martins
Hello again.
Was this bug fixed? Or should I change its state or even submit a patch?
Was this bug fixed? Or should I change its state or even submit a patch?
Lift bugs were moved to Github a while back. See here: https://github.com/lift/framework/pull/1183
on 2013-01-22 16:00 *
By Alexandre Martins
Sorry and thanks for the quick response.