1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the test suite of the Qt Toolkit. |
7 ** This file is part of the test suite of the Qt Toolkit. |
8 ** |
8 ** |
201 void QTBUG_5251(); |
201 void QTBUG_5251(); |
202 void QTBUG_6421_data() { generic_data("QOCI"); } |
202 void QTBUG_6421_data() { generic_data("QOCI"); } |
203 void QTBUG_6421(); |
203 void QTBUG_6421(); |
204 void QTBUG_6618_data() { generic_data("QODBC"); } |
204 void QTBUG_6618_data() { generic_data("QODBC"); } |
205 void QTBUG_6618(); |
205 void QTBUG_6618(); |
|
206 void QTBUG_6852_data() { generic_data("QMYSQL"); } |
|
207 void QTBUG_6852(); |
206 |
208 |
207 private: |
209 private: |
208 // returns all database connections |
210 // returns all database connections |
209 void generic_data(const QString &engine=QString()); |
211 void generic_data(const QString &engine=QString()); |
210 void dropTestTables( QSqlDatabase db ); |
212 void dropTestTables( QSqlDatabase db ); |
2983 "end\n" )); |
2985 "end\n" )); |
2984 q.exec( "{call " + qTableName( "tst_raiseError" ) + "}" ); |
2986 q.exec( "{call " + qTableName( "tst_raiseError" ) + "}" ); |
2985 QVERIFY(q.lastError().text().contains(errorString)); |
2987 QVERIFY(q.lastError().text().contains(errorString)); |
2986 } |
2988 } |
2987 |
2989 |
|
2990 void tst_QSqlQuery::QTBUG_6852() |
|
2991 { |
|
2992 QFETCH( QString, dbName ); |
|
2993 QSqlDatabase db = QSqlDatabase::database( dbName ); |
|
2994 CHECK_DATABASE( db ); |
|
2995 if ( tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 ) |
|
2996 QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); |
|
2997 |
|
2998 QSqlQuery q(db); |
|
2999 QString tableName(qTableName(QLatin1String("bug6421"))), procName(qTableName(QLatin1String("bug6421_proc"))); |
|
3000 |
|
3001 QVERIFY_SQL(q, exec("DROP PROCEDURE IF EXISTS "+procName)); |
|
3002 tst_Databases::safeDropTable(db, tableName); |
|
3003 QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(\n" |
|
3004 "MainKey INT NOT NULL,\n" |
|
3005 "OtherTextCol VARCHAR(45) NOT NULL,\n" |
|
3006 "PRIMARY KEY(`MainKey`))")); |
|
3007 QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES(0, \"Disabled\")")); |
|
3008 QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES(5, \"Error Only\")")); |
|
3009 QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES(10, \"Enabled\")")); |
|
3010 QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES(15, \"Always\")")); |
|
3011 QVERIFY_SQL(q, exec("CREATE PROCEDURE "+procName+"()\n" |
|
3012 "READS SQL DATA\n" |
|
3013 "BEGIN\n" |
|
3014 " SET @st = 'SELECT MainKey, OtherTextCol from "+tableName+"';\n" |
|
3015 " PREPARE stmt from @st;\n" |
|
3016 " EXECUTE stmt;\n" |
|
3017 "END;")); |
|
3018 |
|
3019 QVERIFY_SQL(q, exec("CALL "+procName+"()")); |
|
3020 QVERIFY_SQL(q, next()); |
|
3021 QCOMPARE(q.value(0).toInt(), 0); |
|
3022 QCOMPARE(q.value(1).toString(), QLatin1String("Disabled")); |
|
3023 } |
|
3024 |
|
3025 |
2988 QTEST_MAIN( tst_QSqlQuery ) |
3026 QTEST_MAIN( tst_QSqlQuery ) |
2989 #include "tst_qsqlquery.moc" |
3027 #include "tst_qsqlquery.moc" |