diff options
author | Bill King <bill.king@nokia.com> | 2009-06-12 00:29:44 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-06-15 00:31:07 (GMT) |
commit | c9f77564df14f91276e9ca693a9b3f339dab9334 (patch) | |
tree | 5c87e861a3973433c2b01ece730164d63a5dab95 /src/sql/kernel/qsqlresult.cpp | |
parent | ba097c23159c1ec026b8b8772d1a9c5e72f2a681 (diff) | |
download | Qt-c9f77564df14f91276e9ca693a9b3f339dab9334.zip Qt-c9f77564df14f91276e9ca693a9b3f339dab9334.tar.gz Qt-c9f77564df14f91276e9ca693a9b3f339dab9334.tar.bz2 |
Stage 1 of incorporating database level precision policy.
Queries now ask the database object what precision they should be,
allows for setting precision policies on sql models, where previously
this was not available. Also fixes some failing precisionpolicy implementations,
as well as working around the fact qstring can't convert from "123.00" to
an int based type.
Diffstat (limited to 'src/sql/kernel/qsqlresult.cpp')
-rw-r--r-- | src/sql/kernel/qsqlresult.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index 180bfc7..a621b24 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -48,6 +48,7 @@ #include "qsqlresult.h" #include "qvector.h" #include "qsqldriver.h" +#include <QDebug> QT_BEGIN_NAMESPACE @@ -64,7 +65,7 @@ class QSqlResultPrivate public: QSqlResultPrivate(QSqlResult* d) : q(d), sqldriver(0), idx(QSql::BeforeFirstRow), active(false), - isSel(false), forwardOnly(false), bindCount(0), binds(QSqlResult::PositionalBinding) + isSel(false), forwardOnly(false), precisionPolicy(QSql::LowPrecisionDouble), bindCount(0), binds(QSqlResult::PositionalBinding) {} void clearValues() @@ -104,6 +105,7 @@ public: bool isSel; QSqlError error; bool forwardOnly; + QSql::NumericalPrecisionPolicy precisionPolicy; int bindCount; QSqlResult::BindingSyntax binds; @@ -249,6 +251,9 @@ QSqlResult::QSqlResult(const QSqlDriver *db) { d = new QSqlResultPrivate(this); d->sqldriver = db; + if(db) { + setNumericalPrecisionPolicy(db->numericalPrecisionPolicy()); + } } /*! @@ -965,8 +970,14 @@ void QSqlResult::detachFromResultSet() */ void QSqlResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) { - if (driver()->hasFeature(QSqlDriver::LowPrecisionNumbers)) - virtual_hook(SetNumericalPrecision, &policy); + d->precisionPolicy = policy; +} + +/*! \internal + */ +QSql::NumericalPrecisionPolicy QSqlResult::numericalPrecisionPolicy() const +{ + return d->precisionPolicy; } /*! \internal |