tags:

views:

47

answers:

2

I'm new to Scala and Lift, coming from a slightly odd background in PLT Scheme. I've done a quick search on this topic and found lots of questions but no answers. I'm probably looking in the wrong place.

I've been working my way through tutorials on using Mapper to create database-backed objects, and I've hit a stumbling block: what types should be used to stored optional attribute values.

For example, a simple ToDo object might comprise a title and an optional deadline (e.g. http://rememberthemilk.com). The former would be a MappedString, but the latter could not be a MappedDateTime since the type constraints on the field require, say, defaultValue to return a Date (rather than a Date or null/false/???).

Is an underlying NULL handled by the MappedField subclasses? Or are there optional equivalents to things like MappedInt, MappedString, MappedDateTime that allow the value to be NULL in the database? Or am I approaching this in the wrong way?

+3  A: 

The best place to have Lift questions answered is the Lift group. They aren't into Stack Overflow, but if you do go to their mailing list, they are very receptive and helpful.

Daniel
Good advice indeed...
David Brooks
I'd be voting you up, had I enough reputation to do so :(
David Brooks
+2  A: 

David Pollak replied with:

Mapper handles nulls for non-JVM primitives (e.g., String, Date, but not Int, Long, Boolean). You'll get a "null" from the MappedDateTime.is method.

... which is spot on.

David Brooks