core: Workaround Qt 4 SQL bindValue() duplicates
Workaround Qt 4 QSqlQuery::bindValue() not handling duplicate
parameter names by giving every duplicated parameter a unique name.
Qt 5 handles this as one expects, so this doesn't need forward-ported
to 0.14/master where Qt 4 support has been dropped.
Applies to SQLite and PostgreSQL.
Note: PostgreSQL prepared statements properly handle repeated "$"
parameters, so there's no need to modify those.
Test case for prepared statements:
> PREPARE qcore_test_var
AS SELECT * FROM buffer WHERE bufferid = $1 AND userid = $1
AND networkid = $1;
> EXECUTE qcore_test_var(1);
Gives a result if bufferid = userid = networkid = 1 exists.
Credit to @justJanne for finding the root cause of the issue, and
suggesting the fix, and to 'galfwender' and @darkstar for reporting.
Fixes #1506
See https://doc.qt.io/archives/qt-4.8/qsqlquery.html#bindValue
And https://doc.qt.io/qt-5/qsqlquery.html#bindValue
14 files changed: