summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorBill King <bill.king@nokia.com>2009-07-13 04:01:25 (GMT)
committerBill King <bill.king@nokia.com>2009-07-13 04:01:25 (GMT)
commitb7d274c1fc818b347ff9256a00e4f667f0bd1556 (patch)
tree2e8b9d6d920064b91a236aee1fd518f3c5b7c3ab /src/sql
parentc402f363d8502c688433eb4f21ba3528d9ac89e5 (diff)
parentde07df9001586cc18ae267591359541b7ea494a0 (diff)
downloadQt-b7d274c1fc818b347ff9256a00e4f667f0bd1556.zip
Qt-b7d274c1fc818b347ff9256a00e4f667f0bd1556.tar.gz
Qt-b7d274c1fc818b347ff9256a00e4f667f0bd1556.tar.bz2
Merge commit 'origin/4.5'
Conflicts: src/plugins/kbddrivers/usb/main.cpp tests/auto/qnetworkreply/tst_qnetworkreply.cpp tests/auto/qwidget/tst_qwidget.cpp
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp36
-rw-r--r--src/sql/models/qsqltablemodel.cpp3
2 files changed, 24 insertions, 15 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index bd93a9a..c61c526 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -59,21 +59,29 @@
#include <pg_config.h>
#include <stdlib.h>
-#if defined(_MSC_VER)
-#include <float.h>
-#define isnan(x) _isnan(x)
-int isinf(double x)
-{
- if(_fpclass(x) == _FPCLASS_NINF)
- return -1;
- else if(_fpclass(x) == _FPCLASS_PINF)
- return 1;
- else return 0;
-}
-#else
#include <math.h>
+// below code taken from an example at http://www.gnu.org/software/hello/manual/autoconf/Function-Portability.html
+#ifndef isnan
+ # define isnan(x) \
+ (sizeof (x) == sizeof (long double) ? isnan_ld (x) \
+ : sizeof (x) == sizeof (double) ? isnan_d (x) \
+ : isnan_f (x))
+ static inline int isnan_f (float x) { return x != x; }
+ static inline int isnan_d (double x) { return x != x; }
+ static inline int isnan_ld (long double x) { return x != x; }
#endif
+#ifndef isinf
+ # define isinf(x) \
+ (sizeof (x) == sizeof (long double) ? isinf_ld (x) \
+ : sizeof (x) == sizeof (double) ? isinf_d (x) \
+ : isinf_f (x))
+ static inline int isinf_f (float x) { return isnan (x - x); }
+ static inline int isinf_d (double x) { return isnan (x - x); }
+ static inline int isinf_ld (long double x) { return isnan (x - x); }
+#endif
+
+
// workaround for postgres defining their OIDs in a private header file
#define QBOOLOID 16
#define QINT8OID 20
@@ -615,10 +623,9 @@ static QPSQLDriver::Protocol getPSQLVersion(PGconn* connection)
{
QPSQLDriver::Protocol serverVersion = QPSQLDriver::Version6;
PGresult* result = PQexec(connection, "select version()");
- int status = PQresultStatus(result);
+ int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) {
QString val = QString::fromAscii(PQgetvalue(result, 0, 0));
- PQclear(result);
QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)"));
rx.setMinimal(true); // enforce non-greedy RegExp
if (rx.indexIn(val) != -1) {
@@ -659,6 +666,7 @@ static QPSQLDriver::Protocol getPSQLVersion(PGconn* connection)
}
}
}
+ PQclear(result);
if (serverVersion < QPSQLDriver::Version71)
qWarning("This version of PostgreSQL is not supported and may not work.");
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 156af26..4315a8c 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -205,7 +205,7 @@ bool QSqlTableModelPrivate::exec(const QString &stmt, bool prepStatement,
editQuery.addBindValue(rec.value(i));
}
for (i = 0; i < whereValues.count(); ++i) {
- if (whereValues.isGenerated(i))
+ if (whereValues.isGenerated(i) && !whereValues.isNull(i))
editQuery.addBindValue(whereValues.value(i));
}
@@ -538,6 +538,7 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
isOk = updateRowInTable(index.row(), d->editBuffer);
if (isOk)
select();
+ emit dataChanged(index, index);
break; }
case OnRowChange:
if (index.row() == d->insertIndex) {