Boost logo

Boost :

From: Julien Blanc (julien.blanc_at_[hidden])
Date: 2022-05-11 07:28:38


Le 2022-05-10 22:33, Marcelo Zimbres Silva via Boost a écrit :

> 6) ================================
>
>> https://anarthal.github.io/mysql/mysql/ref/boost__mysql__value/get_std_optional.html
>> https://anarthal.github.io/mysql/mysql/ref/boost__mysql__value/get_optional.html
>
> Sounds also unusual to have two member functions for the different
> versions of optional. I suggest using the boost version until we
> transition to C++17.

I probably won't have the time to do a proper review, but had a quick
look at the documentation and this interface surprised me a bit. I was
expecting optional (whether std or boost) to be used to map nullable
values, but it seems that's not the case. It seems this interface will
return an empty optional if using a wrong type (like trying to get an
int from a string column), but the doc is silent on what it will do if
trying to get an int from a nullable int which is actually NULL (my
understanding is that it would return an empty optional). It bothers me
a bit that these two use cases are handled the same way, because one of
them is a valid use, and the other is a mismatch between the program and
the database schema that i would like to diagnose.

I understand this issue is non-trivial, since when the value is
retrieved from the row object, the information about the type of the
data in the DB (and thus its nullability) is lost. However, it seems
odd. It may be of interest to store whether the field is null in a
independent way from its type, instead of relying on a single null type.

Or maybe i just missed something obvious.

Regards,

Julien


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk