Changeset 561 for trunk/src/sql/kernel/qsqldatabase.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/sql/kernel/qsqldatabase.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtSql module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 130 130 { 131 131 public: 132 QSqlDatabasePrivate(QSqlDriver *dr = 0): 132 QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0): 133 q(d), 133 134 driver(dr), 134 135 port(-1) 135 136 { 136 137 ref = 1; 138 if(driver) 139 precisionPolicy = driver->numericalPrecisionPolicy(); 140 else 141 precisionPolicy= QSql::LowPrecisionDouble; 137 142 } 138 143 QSqlDatabasePrivate(const QSqlDatabasePrivate &other); … … 143 148 144 149 QAtomicInt ref; 150 QSqlDatabase *q; 145 151 QSqlDriver* driver; 146 152 QString dbname; … … 152 158 QString connOptions; 153 159 QString connName; 160 QSql::NumericalPrecisionPolicy precisionPolicy; 154 161 155 162 static QSqlDatabasePrivate *shared_null(); … … 165 172 { 166 173 ref = 1; 174 q = other.q; 167 175 dbname = other.dbname; 168 176 uname = other.uname; … … 173 181 connOptions = other.connOptions; 174 182 driver = other.driver; 183 precisionPolicy = other.precisionPolicy; 175 184 } 176 185 … … 217 226 { 218 227 static QSqlNullDriver dr; 219 static QSqlDatabasePrivate n( &dr);228 static QSqlDatabasePrivate n(NULL, &dr); 220 229 return &n; 221 230 } … … 282 291 void QSqlDatabasePrivate::copy(const QSqlDatabasePrivate *other) 283 292 { 293 q = other->q; 284 294 dbname = other->dbname; 285 295 uname = other->uname; … … 289 299 port = other->port; 290 300 connOptions = other->connOptions; 301 precisionPolicy = other->precisionPolicy; 291 302 } 292 303 … … 353 364 354 365 \ingroup database 355 \mainclass 366 356 367 \inmodule QtSql 357 368 … … 379 390 name argument, the default connection is assumed. The following 380 391 snippet shows how to create and open a default connection to a 381 MySQL database:392 PostgreSQL database: 382 393 383 394 \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 0 … … 444 455 The database connection is referred to by \a connectionName. The 445 456 newly added database connection is returned. 457 458 If \a type is not available or could not be loaded, isValid() returns false. 446 459 447 460 If \a connectionName is not specified, the new connection becomes … … 659 672 QSqlDatabase::QSqlDatabase(const QString &type) 660 673 { 661 d = new QSqlDatabasePrivate( );674 d = new QSqlDatabasePrivate(this); 662 675 d->init(type); 663 676 } … … 671 684 QSqlDatabase::QSqlDatabase(QSqlDriver *driver) 672 685 { 673 d = new QSqlDatabasePrivate( driver);686 d = new QSqlDatabasePrivate(this, driver); 674 687 } 675 688 … … 950 963 The \e{database name} is not the \e{connection name}. The 951 964 connection name must be passed to addDatabase() at connection 952 object create time. 965 object create time. 953 966 954 967 For the QOCI (Oracle) driver, the database name is the TNS … … 1218 1231 \i CLIENT_INTERACTIVE 1219 1232 \i UNIX_SOCKET 1233 \i MYSQL_OPT_RECONNECT 1220 1234 \endlist 1221 1235 … … 1253 1267 \list 1254 1268 \i QSQLITE_BUSY_TIMEOUT 1269 \i QSQLITE_OPEN_READONLY 1255 1270 \endlist 1256 1271 … … 1470 1485 } 1471 1486 1487 /*! 1488 \since 4.6 1489 1490 Sets the default numerical precision policy used by queries created 1491 on this database connection to \a precisionPolicy. 1492 1493 Note: Drivers that don't support fetching numerical values with low 1494 precision will ignore the precision policy. You can use 1495 QSqlDriver::hasFeature() to find out whether a driver supports this 1496 feature. 1497 1498 Note: Setting the default precision policy to \a precisionPolicy 1499 doesn't affect any currently active queries. 1500 1501 \sa QSql::NumericalPrecisionPolicy, numericalPrecisionPolicy(), 1502 QSqlQuery::setNumericalPrecisionPolicy(), QSqlQuery::numericalPrecisionPolicy() 1503 */ 1504 void QSqlDatabase::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy) 1505 { 1506 if(driver()) 1507 driver()->setNumericalPrecisionPolicy(precisionPolicy); 1508 d->precisionPolicy = precisionPolicy; 1509 } 1510 1511 /*! 1512 \since 4.6 1513 1514 Returns the current default precision policy for the database connection. 1515 1516 \sa QSql::NumericalPrecisionPolicy, setNumericalPrecisionPolicy(), 1517 QSqlQuery::numericalPrecisionPolicy(), QSqlQuery::setNumericalPrecisionPolicy() 1518 */ 1519 QSql::NumericalPrecisionPolicy QSqlDatabase::numericalPrecisionPolicy() const 1520 { 1521 if(driver()) 1522 return driver()->numericalPrecisionPolicy(); 1523 else 1524 return d->precisionPolicy; 1525 } 1526 1527 1472 1528 #ifndef QT_NO_DEBUG_STREAM 1473 1529 QDebug operator<<(QDebug dbg, const QSqlDatabase &d)
Note:
See TracChangeset
for help on using the changeset viewer.