Interbase: Handle EXECUTE BLOCK statements correctly
Since an EXECUTE BLOCK statement can have a mix of ? and :var syntax then a special case for this needs to be added so that it does not try to convert the :var parts into positional placeholders as they need to kept as-is when preparing such a statement. Pick-to: 5.15 Fixes: QTBUG-83152 Change-Id: Iff891207ad6dea1681a1b3a335acbbbb668b465d Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
parent
46c1e60989
commit
65afcef217
@ -112,6 +112,13 @@ QString QSqlResultPrivate::positionalToNamedBinding(const QString &query) const
|
||||
|
||||
QString QSqlResultPrivate::namedToPositionalBinding(const QString &query)
|
||||
{
|
||||
// In the Interbase case if it is an EXECUTE BLOCK then it is up to the
|
||||
// caller to make sure that it is not using named bindings for the wrong
|
||||
// parts of the query since Interbase uses them literally
|
||||
if (sqldriver->dbmsType() == QSqlDriver::Interbase &&
|
||||
query.trimmed().startsWith(QLatin1String("EXECUTE BLOCK"), Qt::CaseInsensitive))
|
||||
return query;
|
||||
|
||||
int n = query.size();
|
||||
|
||||
QString result;
|
||||
|
@ -184,6 +184,8 @@ private slots:
|
||||
void sqliteVirtualTable();
|
||||
void mysql_timeType_data() { generic_data("QMYSQL"); }
|
||||
void mysql_timeType();
|
||||
void ibase_executeBlock_data() { generic_data("QIBASE"); }
|
||||
void ibase_executeBlock();
|
||||
|
||||
void task_217003_data() { generic_data(); }
|
||||
void task_217003();
|
||||
@ -4797,5 +4799,25 @@ void tst_QSqlQuery::ibaseArray()
|
||||
QCOMPARE(qry.value(3).toList(), boolArray.toList());
|
||||
}
|
||||
|
||||
void tst_QSqlQuery::ibase_executeBlock()
|
||||
{
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
QSqlQuery qry(db);
|
||||
QVERIFY_SQL(qry, prepare("execute block (x double precision = ?, y double precision = ?) "
|
||||
"returns (total double precision) "
|
||||
"as "
|
||||
"begin "
|
||||
"total = :x + :y; "
|
||||
"suspend; "
|
||||
"end"));
|
||||
qry.bindValue(0, 2);
|
||||
qry.bindValue(1, 2);
|
||||
QVERIFY_SQL(qry, exec());
|
||||
QVERIFY(qry.next());
|
||||
QCOMPARE(qry.value(0).toInt(), 4);
|
||||
}
|
||||
|
||||
QTEST_MAIN( tst_QSqlQuery )
|
||||
#include "tst_qsqlquery.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user