summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
Commit message (Collapse)AuthorAgeFilesLines
* Convert Boolean value into integerHonglei Zhang2012-04-021-0/+61
| | | | | | | | | | | | | According to documentation, SQLite doesn't have a separate Boolean storage class. Instead, values are stored as integers 0(false) and 1(true). In QSqlQuery::bindValue(), if a boolean value is bound to a placeholder, it is converted to text true and false. This fix converts boolean value to integer 0 and 1. Task-number: QTBUG-23895 Change-Id: I4945971172f0b5e5819446700390033a1a4ce301 Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* Add payload to QSqlDriver notification with PSQL implementation.Matt Newell2012-03-311-4/+6
| | | | | | | | | | | | | | | | | | | Postgres async notifications can contain a payload parameter that is currently discarded. This patch provides the QSqlDriver api change necessary to deliver a payload with each emitted notification by adding a QVariant parameter to the notification signal. It also provides the implementation for the qsqlpsql driver. The qsql_ibase driver has been updated to reflect the change to the notification signal signature. The eventNotificationPSQL test in the qsqldatabase test has been expanded to test proper payload sending and receiving. All tests/auto/sql/kernel tests have been run with sqllite and postgres with no regressions. Task-number: QTBUG-13500 Change-Id: I9137f6acc8cfca93f45791ca930e0287d93d5d0d Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* Expand QtSql tests covering boundValues and boundValueNameMatt Newell2012-03-311-12/+75
| | | | | | | | Tests added that cover boundValues with positional binding, and boundValueName. Change-Id: I2962d76607b716d19d3e0be958109be2f032f2d9 Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* Fix postgres notification support in the QPSQLDriver.Matt Newell2012-03-301-6/+5
| | | | | | | | | | | | | | | | | | | | | This patch fixes a critical bug in the qsqlpsql driver where notifications aren't delivered when received. Any blocking libpq function(specifically PQexec) will read all the incoming data from the socket, including any pending notifications. This would cause the socket notifier to never be fired for incoming notifications that are already queued inside libpq. The qsqldriver test case was skipping the postgres notification test because of this bug, now its enabled and passing. In order to fix this bug I made a wrapper function for PQexec in QPSQLDriverPrivate that calls _q_handleNotification via QMetaObject::callMethod QueuedConnection in order to deliver pending notifications when control returns to the event loop. I also added a flag to ensure only one call is made each time the event loop is entered. Change-Id: I19f5297094ae7ae46bfb0717e4fca744d69f7b92 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* Fix crash when an invalid filter is setHonglei Zhang2012-03-301-0/+23
| | | | | | | | | | | | | QSqlTableModel::headerData() generates a crash if an invalid filter is set. QSqlQueryModel::indexInQuery() should check the index value before applied to d->colOffsets[]. QSqlQueryModel::initRecordAndPrimaryIndex() is updated to sync the size of rec and colOffsets. Task-number: QTBUG-23879 Change-Id: Ic9f88bb288592aa6fb3c1415cc818632dadaab56 Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* Allow named bind values to be used multiple times per queryMatt Newell2012-03-301-4/+18
| | | | | | | | | | | Prepared queries should be able to use a name parameter more than once. Currently this will result in undefined behavior and crashes. This patch fixes the bug and implements the needed test case. Task-number: QTBUG-6420 Change-Id: I07d6537e432a9b2781e9ef3d9f597bceb054527e Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* Fix compilation of tst_QSqlThread: no need to use QBasicAtomicInt hereThiago Macieira2012-03-241-1/+1
| | | | | | Change-Id: Ib474fe62501ee1ee5e3d7008c3b561f8db79265c Reviewed-by: Mark Brand <mabrand@mabrand.nl> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSqlTableModel::removeRows() enforce edit strategyMark Brand2012-03-151-1/+8
| | | | | | | | | | | | | | For OnFieldChange and OnRowChange, we don't want more than one row in the cache with uncommitted changes. This could happen if deletion in the database fails while other changes are pending. Chosen solution is to return false if other rows have pending changes. Also, we only allow 1 row removed at a time. Updated test, changes and documentation. Change-Id: I68baf6d221789b4754e891535070011c759a2155 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel::setData(): no longer autosubmit for OnRowChangeMark Brand2012-03-152-0/+22
| | | | | | | | | | | | | | | | The model can never do a good job of knowing when user moves to a new row in the view. Faking it by detecting when another row is changed was not a good solution because it cannot detect when the last edited row is left. Either the view should automatically submit when the user leaves a row or the application should provide a way to submit. This change made it possible to reuse the logic of flags() in setData(). Change-Id: I2550e5b113bceba1a852fc21203babeca07c5748 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel: disallow insert if changes are pendingMark Brand2012-03-151-0/+4
| | | | | | | | For OnFieldChange and OnRowChange, inserting rows should not be allowed if there are pending changes in cache. Change-Id: Ia794332959a35a1de87e798ba1a74ace3dfae68f Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel::setData()/setRecord(): fix incorrect rowMark Brand2012-03-151-4/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For OnFieldChange and OnRowChange, before submitting new changes, setData() and setRecord() attempt to submit pending changes and revert them upon failure. However, they fail to consider that reverting pending insertions removes rows from the model. As a result, the new change can be applied to a row higher than intended. One possible solution would be to adjust the targetted index for the removed rows, so that the intended row is affected by the new change. But this still causes the strange editing experience as rows jump up just as they are being edited. It does not seem right in the first place for the model to initiate reverting changes. It should be up to the application to decide what to do when data cannot be committed. In particular, setData() and setRecord() should not have the side effect of reverting already pending changes. The chosen solution is simply to refuse new changes that don't make sense for the edit strategy. For OnFieldChange, flag() will indicate read-only when editing is blocked by a pending change. Since setData() and setRecord() submit data immediately for OnFieldChange, it no longer makes sense to resubmit changes automatically before a new change. For OnRowChange, setData() keeps the behavior of automatically submitting a pending row before starting on a new row. This is historical behavior and is probably motivated by the fact that QTableView does not automatically call submit() when editing leaves a row. The obvious shortcoming of this is that the last row to be edited will not be submitted automatically. It also prevents us from flagging rows other than the pending row as read-only. For OnRowChange, setRecord(), being row-oriented by nature, should submit the change immediately rather than waiting for the next call to setRecord(). This makes setRecord() consistent with insertRecord(). Change-Id: Icb4019d8b7c53a7ee48f8121a7a525e8bc35d523 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel::isDirty(): new overloaded methodMark Brand2012-03-121-0/+162
| | | | | | | | | | | Checks if model has any changes to submit. Includes new test covering isDirty(index) as well the new overloaded function. Task-number: QTBUG-3108 Change-Id: I0ccbda45d5d9f06434cf1e1c037a9efb76d0cc37 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* Make tst_qsql.cpp independent of QtWidgetsDebao Zhang2012-03-112-3/+3
| | | | | | Change-Id: I032902bea6fe2c7d9eb0491886fded7602ae2bcc Reviewed-by: Mark Brand <mabrand@mabrand.nl> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Improve type detection for query resultsAndy Shaw2012-03-071-0/+118
| | | | | | | | | | | | | | When an aggregate function is used for a column in a SQL resultset then it should ensure that the right data type is reported for that column. This also concerns expressions when the returned column does not map directly to a table column. Test included for this. Task-number: QTBUG-22038 Change-Id: I07487694c0ed393d46af06e232914fe923356a99 Reviewed-by: Mark Brand <mabrand@mabrand.nl> Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* QSqlTableModel: use selectRow() for field and row edit strategiesMark Brand2012-03-072-14/+76
| | | | | | | | | | | | | | | | Calling select refreshes the query data but disrupts view navigation. For OnFieldChange and OnRecordChange it makes sense to only select the row in question. This does not disturb view navigation. Assume disruption of view navigation is not a problem for OnManualSubmit because the user or application decides when submitAll is called. Task-number: QTBUG-2875 Change-Id: I1e5f68668fb9102f6296d67d543e80daa403f1c4 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel: handle changes between submit and selectMark Brand2012-03-071-4/+4
| | | | | | | | | | | | | | | | | | | | Once an insert has been submitted, the cached record behaves like an update. For row bookkeeping, we still have to remember that it was originally inserted and is not in the query rows. Between submitting a delete and selecting, we remove the values from the deleted record. This causes a blank row to be displayed. Read-only flag is set for cells in deleted row. Reverting between submit and select means going back to the last submitted values. When removing rows, it's better to process from highest row numbers to lowest. This avoids complications with higher rows shifting down when lower rows are removed. Change-Id: I8752fa11f7a1b88f2a71b9e03a020ac37e62487f Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* restore previously non-working disabled testMark Brand2012-02-281-2/+1
| | | | | Change-Id: I419863a681f7be96cb855a274c68eaea25efebcb Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::commitAll(): replace row removal hackMark Brand2012-02-151-3/+7
| | | | | | | | | | | | | | | | | | | The purpose of the hack was to fool QSqlQueryModel into signaling the removal of extra rows via rowsRemoved(). The extra rows are the inserted rows generated by QSqlTableModel. While it is important to signal the removal of all the rows before requerying after committing changes, there is a cleaner way. The table model should remove its rows before the query model removes its rows. Iterating backwards avoids having to decrement row numbers above ones being removed. Expected test results have been adjusted for these changes. Change-Id: I0e8aa81f5e7b8fea5922f5ffd1cfb4a932313a10 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* update comment on testMark Brand2012-02-141-1/+1
| | | | | | | | Fix up for f5e1da12f0e7bdeee4db74acc52dfabeb12a4e31. Change-Id: I3a730ce7e47d71551a46cc105ba2d1fe4e33b65b Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* QSqlTableModel::setRecord(): emit dataChanged() consistentlyMark Brand2012-02-081-3/+3
| | | | | | | | | | | | | | | Previously, if any fields in the supplied record could not be matched with a column in the target table, dataChanged() was supressed for all columns for OnManualSubmit. This is not good because it prevents other views from noticing the fields that *do* change. It's simplest and probably more efficient just to emit dataChanged() once for the whole row. Fewer signals need to be processed and in typical cases much or all of the row is likely to be changed anyway. Change-Id: Ib56bf9a18e51b9cb85771acefcb2bf26e295a54e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QSqlTableModel::setRecord(): do not try to detect value changesMark Brand2012-02-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | In an apparent attempt to be economical with emitting dataChanged() and submitting SQL to the databse, setRecord() compares each field value of the record with the old value, taking action only when a difference is detected. Several complaints against this code are: -The comparision does not work on float type. -It is really up to the application and database to decide this. The model should make few assumptions. The application has the option to omit fields from the record that should be ignored. -The current behavior seems to assume that the "old" values are the current state of the database, but the database may have changed since the model was last refreshed. -The code compares the value from record(), which probably corresponds to the EditRole, with the DisplayRole value from data(). Change-Id: I11477c185eb411d442144dc682893d0df12d03d5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QSqlTableModel::removeRows(): don't emit extra beforeDeleteMark Brand2012-02-071-4/+3
| | | | | | | | Qt 5 seems like a welcome opportunity to stop emitting this spurious beforeDelete signal. Change-Id: Ib8628343ca9b8fdd85c154a206c7e2bf2c4c9dc1 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Handle the 'real' datatype correctly in the SQLite driverAndy Shaw2012-02-032-1/+31
| | | | | | | | | | | | | | | The 'real' datatype should be seen as a QVariant::Double type and not as a QVariant::String type otherwise it does not get presented correctly when using a non Qt application to access it. Test is included for QSqlQuery. Task-number: QTBUG-16373 Change-Id: Ie323ce49eb95e4d6bb4c3814ba9a957a63f4b259 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com> (cherry picked from commit b23631015c23a49e3b4d296ea0a6266bfce3d4f1) Reviewed-by: Mark Brand <mabrand@mabrand.nl>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-3012-12/+12
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-2312-12/+12
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-0512-12/+12
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Check driver validity before using itHonglei Zhang2011-12-121-2/+7
| | | | | | | | | | | | Even though it is stated in the documentation that the SQL driver must remain valid during the life time of QSqlQuery, there are users who don't follow the rule. It's common that the destructor of QSqlQuery is called after the driver is already deleted. This fix checks the validity of the SQLite driver before QSqliteResult uses it in destructor. Task-number: QTBUG-16967 Change-Id: If0f52113f12e14102da1671cd6e12bdaa267114f Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Remove TESTED_CLASS/TESTED_FILES comments from tests.Jason McDonald2011-12-0610-35/+0
| | | | | | | | | These comments were mostly empty or inaccurate. Appropriate naming of tests and appropriate placement of tests within the directory tree provide more reliable indicators of what is being tested. Change-Id: Ib6bf373d9e79917e4ab1417ee5c1264a2c2d7027 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Fix tst_qsql crashes on Mac OS XHonglei Zhang2011-12-022-13/+15
| | | | | | | | | | | | In tst_qsql, there are function calls to QApplication(argc, 0, false), where argc is zero. According to the documentation, argc must be greater than zero and argv must contain at least one valid character string. The misuse of this API has no problem on any platform other than Mac OS. This commit has fixed the crash by passing valid dummy parameters. Task-number: QTBUG-22811 Change-Id: I42b26d66f0becb7a942896e6ddcaea52ff720a48 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* QSqlRelationalTableModel doesn't follow relations on the first columnHonglei Zhang2011-12-021-0/+55
| | | | | | | | | | QSqlRelationalTableModel doesn't follow relations on the first column of a table. The DisplayRole and the EditRole for indexes on column 0 are always the same. The bug is found in QSqlRelationalTableModel::data. Task-number: QTBUG-20038 Change-Id: Ie1e98b5f46ffc171113f2d51b9b19ff5febb1c3c Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Fix sqlite driver memory eating due to close failureHonglei Zhang2011-11-301-0/+49
| | | | | | | | | | | | | | If an ongoing query is not finalized before close function is called, sqlite driver still tries to close the connection to sqlite. In this case, sqlite reports an error to sqlite driver which is not reported to the client. The failure in close causes connection to sqlite unclosed and memory is not freed. This fix tries to finalize all queries before close function is called. The close function should succeed. Task-number: QTBUG-16967 Change-Id: I2f10a2a9017446a9d44b693b00464a89625e3602 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* SQLite support only one statement at a timeHonglei Zhang2011-11-231-0/+47
| | | | | | | | | | | SQLite driver support only one statement at a time. This fix makes the exec and prepare call failed if more than one statements are given. This is bug fix for QTBUG-21884. Also the behaviour is documented in the API specification. Task-number: QTBUG-21884 Change-Id: If1e25a0dd9f9ee38961ef478fc7909f6b05e360a Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Re-enable the sql autotests on Mac OS XBradley T. Hughes2011-11-211-0/+1
| | | | | | | | | The QSql test currently crashes, which can destabilize the CI system when attempting to re-enable the autotest. Skip this test for now by disabling the check target for it. Change-Id: I598f8ca7bce6b6f46daf6a053da5571b62486463 Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
* Fix QtSQL auto test server addressesHonglei Zhang2011-10-251-2/+8
| | | | | | | | | Fix QtSQL aoto test server addresses. New servers are located in Brisbane. Old Oslo test servers shall not be used anymore. Change-Id: Icd4ae4c0193f71410d572bfa014272e1e77586c0 Reviewed-by: Trust Me Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* all remaining tests: eliminated usage of qttest_p4.prfRohan McGovern2011-10-2510-20/+30
| | | | | | | | | qttest_p4.prf was added as a convenience for Qt's own autotests in Qt4. It enables various crufty undocumented magic, of dubious value. Stop using it, and explicitly enable the things from it which we want. Change-Id: I02fe27b2c1800f929250fa8694ca2976c9661a12 Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
* test: Split `qsqlquery' unit and benchmark testSergio Ahumada2011-10-232-39/+4
| | | | | | | | | | | | | Moving benchmark test from 'tests/auto' to 'tests/benchmarks'. Also removing 'qttest_p4' usage while we are at it. - void benchmark(); was moved to 'tests/benchmarks/sql/kernel/qsqlquery' Task-number: QTQAINFRA-353 Change-Id: I241bb1a2fba1c1b5524c21e5941a6c5daf5a4a89 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
* Remove SkipMode parameter from QSKIP calls.Jason McDonald2011-10-219-90/+90
| | | | | | | | | The previous commit removed SkipMode from the testlib APi. This commit removes the parameter from all calls to QSKIP. Task-number: QTBUG-21851, QTBUG-21652 Change-Id: I21c0ee6731c1bc6ac6d962590d9b31d7459dfbc5 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Move the non-atomic and implicit functions from QBasicAtomicXXXThiago Macieira2011-10-201-1/+1
| | | | | | | | | Now, users of QBasicAtomicInt and QBasicAtomicPointer must be sure to use .load() and .store() to access the values. Change-Id: I6b48ed175618baf387dd38d821bd50e6e93c082e Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Remove DEPENDS_ON from qtestlib API.Jason McDonald2011-10-191-6/+0
| | | | | | | | | | The DEPENDS_ON macro didn't do anything and has misled many users to think that they can write test functions that depend on other test functions. Task-number: QTBUG-21851 Change-Id: Ibe65b2d5d88bb81b6a0ebbe0b220f7d409a1446c Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove redundant qWarning's.Jason McDonald2011-10-072-6/+2
| | | | | | | | | | The removed warnings just repeat information that is already in the QSKIP's that immediately follow the warnings. Change-Id: Id13158487e8075aab8a8f48955303edde3f4af63 Reviewed-on: http://codereview.qt-project.org/6194 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* No need to return after QSKIP.Jason McDonald2011-10-073-31/+12
| | | | | | | | | QSKIP already causes the test function that calls it to return, so the returns removed by this commit were unreachable. Change-Id: I1fa2f3a3271927d8a600b02d8b31bd81db9146b1 Reviewed-on: http://codereview.qt-project.org/6188 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Tidy qsqldatabase autotestJason McDonald2011-10-061-39/+18
| | | | | | | | | Remove unused macro and remove redundant returns after calls to QSKIP. Change-Id: Ie333801cbec6c3123931f2fedbcd8902cab69a2e Reviewed-on: http://codereview.qt-project.org/6021 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove Symbian-specific code from tests.Jason McDonald2011-09-2911-115/+2
| | | | | | | | | Symbian is not a supported platform for Qt5, so this code is no longer required. Change-Id: I1172e6a42d518490e63e9599bf10579df08259aa Reviewed-on: http://codereview.qt-project.org/5657 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Fix autotest gui/widgets dependenciesKent Hansen2011-09-197-6/+7
| | | | | | | | | | | | | | | | | This is in preparation of removing testlib's dependency on QtGui and QtWidgets. Autotests that need QtWidgets api must explicitly include it (since the types are no longer provided by the QtGui master header). Autotests that don't need QtGui or QtWidgets api shouldn't link against those libraries. Change-Id: I2808289068514fcac582808828ad4634e2631733 Reviewed-on: http://codereview.qt-project.org/5093 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Moved sql autotests into new directory structureJo Asplin2011-09-0637-0/+11910
Task-number: QTBUG-21253 Change-Id: Id20605e1247b080e775968b56ea5f56462ca4c71 Reviewed-on: http://codereview.qt.nokia.com/4127 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>