[Qt-interest] QSqlQuery and placeholders of the same name
Bill KING
bill.king at trolltech.com
Tue Dec 30 06:21:36 CET 2008
It was correctly rejected, as in the sqlite case, placeholders are
handled by the database engine itself and not qt, in this case, sqlite
has failed to bind correctly, even tho we've told it to. In the case of
database engines that don't support parameterised queries, then, we do
substituion ourselves to fill out the query. Honestly, if you're trying
to "be smart" by re-using the binding, don't, there's too many layers
that it can go wrong in, and saving one line of code is really not worth
it in the long run when you factor in testing, debugging, and rewriting
the code in the end anyway to do both bindings.
Anthony Serdyukov wrote:
> Good day.
>
> Just a simple code.
>
> -------------------------------------
> QSqlQuery query;
> query.prepare("select * from some_table where columnA = :param AND
> columnB = :param");
> query.bindValue(":param", someValue);
> query.exec();
> -------------------------------------
>
> But it doesn't work. The placeholders of the same name are not bound correctly.
> First occurrence of :param placeholder gets value of NULL, and the
> second occurrence gets proper value.
>
> I have found a task about it.
> http://trolltech.com/developer/task-tracker/index_html?method=entry&id=77898
> The task is rejected without any explanation.
>
> Could somebody explain this behavior?
>
>
--
Bill King, Software Engineer
Qt Software, Nokia Pty Ltd
Brisbane Office
More information about the Qt-interest-old
mailing list