It would be nice if there could be a generalized way of specifying
optionality for fields.(The first though question is whether the default
behavior is consistent -- do all field types equate NULL with their
default?)
I pasted the names of all the field types (by listing all Mapped*.class
files in target/classes/net/liftweb/mapper). For which of them does it make
sense to have optionality, which of them do, and would it make sense to have
a trait to mix in or some other consistent way to allow nullablility?

MappedBinary, MappedBirthYear, MappedBoolean, MappedCountry,
MappedDate, MappedDateTime, MappedDecimal, MappedDouble, MappedEmail,
MappedEnum, MappedEnumList, MappedFakeClob, MappedForeignKey,
MappedGender, MappedInt, MappedIntIndex, MappedLocale, MappedLong,
MappedLongForeignKey, MappedLongIndex, MappedPassword,
MappedPoliteString, MappedPostalCode, MappedString,
MappedStringForeignKey, MappedStringIndex, MappedText, MappedTextarea,
MappedTime, MappedTimeZone, MappedUniqueId


On Wed, Oct 7, 2009 at 4:36 PM, David Pollak
<feeder.of.the.be...@gmail.com>wrote:

>
>
> On Wed, Oct 7, 2009 at 12:55 PM, harryh <har...@gmail.com> wrote:
>
>>
>> I have a long field in my database that I want to have a unique index
>> (enforced by the database).  Sometimes this field will be empty, in
>> which case I'd like to set it to NULL.  0 won't work because that
>> won't work with the unique index.
>>
>> MappedLong appears to be converting null to 0 internally.
>> Additionally overriding defaultValue for the field and returning null
>> does not appear to work.
>>
>> Is this by design?
>
>
> Yes.
>
>
>> Is it possible that I am misunderstanding something
>> here?
>>
>
> I think you're looking for a MappedOptLong which will treat None (or Empty)
> as NULL and Some(Long) as the value.
>
> Please open a ticket and I'll add the code.
>
>>
>> -harryh
>>
>>
>>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Surf the harmonics
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to