[Development] Proposing QSqlQuery syntax sugar

Thiago Macieira thiago.macieira at intel.com
Tue Sep 18 10:14:20 CEST 2012


On terça-feira, 18 de setembro de 2012 00.24.45, Thiago A. Corrêa wrote:
> Hi,
> 
>       I'd like to propose a templated QSqlQuery::value in the same way
> QVariant::value works. This syntax suggar allows one to write:
> 
>       QSqlQuery query;
>       ...
>       int myvalue = query.value<int>(0);
> 
>       Instead of the current:
>       int myvalue = query.value(0).toInt();
> 
>       And also QSqlQuery::value( const QString& ) overload to obtain
> column values by name instead of column index.
>       Writting code that relies on column names is more robust to
> changes than indexes, yet in current API it's very clumbersome:
> 
>       int myvalue = query.record().value("MyColumn").toInt();
> 
>       I'm not very experienced with Qt workflow, how would one go
> about proposing those changes? Should it be for 5.0.0 or 5.1.0? Can
> such a change be pushed somewhere or should wait for Qt5 release?

This sounds like a new feature, so it should go into 5.1. If you wait a few 
days, we might have the development branch for 5.1 opened.

Since it goes into 5.1, you need to make it work with the current functions, 
retaining source- and binary-compatibility. For that reason, you may not be 
able to name your functions simply "value".

In any case, the module's maintainer (Mark Brand) gets to decide whether the 
feature makes sense and he wants it in his module.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120918/fcbe374a/attachment.sig>


More information about the Development mailing list