[Development] QString behavior change
julien.blanc at nmc-company.com
Tue Aug 11 10:38:27 CEST 2015
Le vendredi 31 juillet 2015 à 09:01 -0700, Thiago Macieira a écrit :
> > <thiago.macieira at intel.com> wrote:
> > > In this particular case, it was reasoned that the API was inconsistent and
> > > broken. So the behaviour was changed intentionally.
> > TBH, it looks like it's still inconsistent (an empty string keeps its
> > storage allocated, a string made of spaces doesn't).
> Right, they are these two cases of trimmed_helper:
> if (begin == str.cbegin() && end == str.cend())
> return str;
> if (begin == end)
> return StringType();
> The consistency of nullness is secondary to performance in this code section.
> I'm not going to add a test before those two.
That point is certainly valid, but i would like to raise the point that
string nullness is a *required* feature for QtSQL (a null QString is
converted to a NULL SQL, whereas a non-null empty QString is converted
to a ''). This makes a huge difference when dealing with not null sql
fields. The fact that trimming an empty string may make it null is
counterintuitive, a behaviour change, and not documented.
So, could you consider returning StringType("") instead ? (unless i’m
wrong, null strings should be handled by the first condition).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Development