
Caleb Epstein wrote:
On 8/18/05, Brock Peabody <brock.peabody@npcinternational.com> wrote:
We could make abstract_row_set::get return an optional<field> instead of a field. Then row::get_field could return an optional as well.
I'd suggest that row::get, however, continue its current behavior which is to return a default constructed value in the presence of null fields.
I think the ability to detect NULL values for columns is a pretty important one in any database interface. Boost.Optional sounds like the perfect solution from a design perspective, but might hurt performance-wise. What if there were a method like bool row::is_null (unsigned int index)?
I think it's reasonable to have to ask whether it's NULL before fetching the value, rather than using optional. Some queries won't return NULLs, either because the column definition is NOT NULL or because the query specified "IFNULL(..., ...)" so the user is the best qualified to know whether it is necessary to test for NULL. If they call get() then the library can assume they know there's a non-NULL value there to get() and not worry about handling a NULL. jon -- "I always keep a supply of liquor handy in case I see a snake, which I also keep handy." - W.C. Fields