summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-10 17:05:10 +0200
committerLars Knoll <lars.knoll@qt.io>2020-10-23 09:58:57 +0200
commit11bad6109606794091adc3b8a14070ac09707f45 (patch)
tree603d07bada752a534a8549c6d008b9b8a4aa832a /src/plugins/sqldrivers
parenta618c260ed0d1de711a5bc20337f9b8c3835c407 (diff)
Deprecate QVariant::Type
It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers')
-rw-r--r--src/plugins/sqldrivers/db2/qsql_db2.cpp72
-rw-r--r--src/plugins/sqldrivers/ibase/qsql_ibase.cpp92
-rw-r--r--src/plugins/sqldrivers/oci/qsql_oci.cpp344
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp74
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp65
5 files changed, 322 insertions, 325 deletions
diff --git a/src/plugins/sqldrivers/db2/qsql_db2.cpp b/src/plugins/sqldrivers/db2/qsql_db2.cpp
index e3cfa0ae15..0e1ff6f2fc 100644
--- a/src/plugins/sqldrivers/db2/qsql_db2.cpp
+++ b/src/plugins/sqldrivers/db2/qsql_db2.cpp
@@ -248,25 +248,25 @@ static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type,
errorCodes.join(QLatin1Char(';')));
}
-static QVariant::Type qDecodeDB2Type(SQLSMALLINT sqltype)
+static QMetaType qDecodeDB2Type(SQLSMALLINT sqltype)
{
- QVariant::Type type = QVariant::Invalid;
+ int type = QMetaType::UnknownType;
switch (sqltype) {
case SQL_REAL:
case SQL_FLOAT:
case SQL_DOUBLE:
case SQL_DECIMAL:
case SQL_NUMERIC:
- type = QVariant::Double;
+ type = QMetaType::Double;
break;
case SQL_SMALLINT:
case SQL_INTEGER:
case SQL_BIT:
case SQL_TINYINT:
- type = QVariant::Int;
+ type = QMetaType::Int;
break;
case SQL_BIGINT:
- type = QVariant::LongLong;
+ type = QMetaType::LongLong;
break;
case SQL_BLOB:
case SQL_BINARY:
@@ -274,19 +274,19 @@ static QVariant::Type qDecodeDB2Type(SQLSMALLINT sqltype)
case SQL_LONGVARBINARY:
case SQL_CLOB:
case SQL_DBCLOB:
- type = QVariant::ByteArray;
+ type = QMetaType::QByteArray;
break;
case SQL_DATE:
case SQL_TYPE_DATE:
- type = QVariant::Date;
+ type = QMetaType::QDate;
break;
case SQL_TIME:
case SQL_TYPE_TIME:
- type = QVariant::Time;
+ type = QMetaType::QTime;
break;
case SQL_TIMESTAMP:
case SQL_TYPE_TIMESTAMP:
- type = QVariant::DateTime;
+ type = QMetaType::QDateTime;
break;
case SQL_WCHAR:
case SQL_WVARCHAR:
@@ -294,13 +294,13 @@ static QVariant::Type qDecodeDB2Type(SQLSMALLINT sqltype)
case SQL_CHAR:
case SQL_VARCHAR:
case SQL_LONGVARCHAR:
- type = QVariant::String;
+ type = QMetaType::QString;
break;
default:
- type = QVariant::ByteArray;
+ type = QMetaType::QByteArray;
break;
}
- return type;
+ return QMetaType(type);
}
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate* d, int i)
@@ -703,7 +703,7 @@ bool QDB2Result::exec()
values[i].detach();
switch (values.at(i).metaType().id()) {
- case QVariant::Date: {
+ case QMetaType::QDate: {
QByteArray ba;
ba.resize(sizeof(DATE_STRUCT));
DATE_STRUCT *dt = (DATE_STRUCT *)ba.constData();
@@ -723,7 +723,7 @@ bool QDB2Result::exec()
*ind == SQL_NULL_DATA ? ind : NULL);
tmpStorage.append(ba);
break; }
- case QVariant::Time: {
+ case QMetaType::QTime: {
QByteArray ba;
ba.resize(sizeof(TIME_STRUCT));
TIME_STRUCT *dt = (TIME_STRUCT *)ba.constData();
@@ -743,7 +743,7 @@ bool QDB2Result::exec()
*ind == SQL_NULL_DATA ? ind : NULL);
tmpStorage.append(ba);
break; }
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QByteArray ba;
ba.resize(sizeof(TIMESTAMP_STRUCT));
TIMESTAMP_STRUCT * dt = (TIMESTAMP_STRUCT *)ba.constData();
@@ -767,7 +767,7 @@ bool QDB2Result::exec()
*ind == SQL_NULL_DATA ? ind : NULL);
tmpStorage.append(ba);
break; }
- case QVariant::Int:
+ case QMetaType::Int:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & 3],
@@ -779,7 +779,7 @@ bool QDB2Result::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
- case QVariant::Double:
+ case QMetaType::Double:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & 3],
@@ -791,7 +791,7 @@ bool QDB2Result::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
int len = values.at(i).toByteArray().size();
if (*ind != SQL_NULL_DATA)
*ind = len;
@@ -806,7 +806,7 @@ bool QDB2Result::exec()
len,
ind);
break; }
- case QVariant::String:
+ case QMetaType::QString:
{
QString str(values.at(i).toString());
if (*ind != SQL_NULL_DATA)
@@ -895,24 +895,24 @@ bool QDB2Result::exec()
for (i = 0; i < values.count(); ++i) {
switch (values[i].metaType().id()) {
- case QVariant::Date: {
+ case QMetaType::QDate: {
DATE_STRUCT ds = *((DATE_STRUCT *)tmpStorage.takeFirst().constData());
values[i] = QVariant(QDate(ds.year, ds.month, ds.day));
break; }
- case QVariant::Time: {
+ case QMetaType::QTime: {
TIME_STRUCT dt = *((TIME_STRUCT *)tmpStorage.takeFirst().constData());
values[i] = QVariant(QTime(dt.hour, dt.minute, dt.second));
break; }
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
TIMESTAMP_STRUCT dt = *((TIMESTAMP_STRUCT *)tmpStorage.takeFirst().constData());
values[i] = QVariant(QDateTime(QDate(dt.year, dt.month, dt.day),
QTime(dt.hour, dt.minute, dt.second, dt.fraction / 1000000)));
break; }
- case QVariant::Int:
- case QVariant::Double:
- case QVariant::ByteArray:
+ case QMetaType::Int:
+ case QMetaType::Double:
+ case QMetaType::ByteArray:
break;
- case QVariant::String:
+ case QMetaType::QString:
if (bindValueType(i) & QSql::Out)
values[i] = QString((const QChar *)tmpStorage.takeFirst().constData());
break;
@@ -1054,13 +1054,13 @@ QVariant QDB2Result::data(int field)
QVariant *v = nullptr;
switch (info.metaType().id()) {
- case QVariant::LongLong:
+ case QMetaType::LongLong:
v = new QVariant((qint64) qGetBigIntData(d->hStmt, field, isNull));
break;
- case QVariant::Int:
+ case QMetaType::Int:
v = new QVariant(qGetIntData(d->hStmt, field, isNull));
break;
- case QVariant::Date: {
+ case QMetaType::QDate: {
DATE_STRUCT dbuf;
r = SQLGetData(d->hStmt,
field + 1,
@@ -1075,7 +1075,7 @@ QVariant QDB2Result::data(int field)
isNull = true;
}
break; }
- case QVariant::Time: {
+ case QMetaType::QTime: {
TIME_STRUCT tbuf;
r = SQLGetData(d->hStmt,
field + 1,
@@ -1090,7 +1090,7 @@ QVariant QDB2Result::data(int field)
isNull = true;
}
break; }
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
TIMESTAMP_STRUCT dtbuf;
r = SQLGetData(d->hStmt,
field + 1,
@@ -1106,10 +1106,10 @@ QVariant QDB2Result::data(int field)
isNull = true;
}
break; }
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
v = new QVariant(qGetBinaryData(d->hStmt, field, lengthIndicator, isNull));
break;
- case QVariant::Double:
+ case QMetaType::Double:
{
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
@@ -1129,7 +1129,7 @@ QVariant QDB2Result::data(int field)
}
break;
}
- case QVariant::String:
+ case QMetaType::QString:
default:
v = new QVariant(qGetStringData(d->hStmt, field, info.length(), isNull));
break;
@@ -1688,7 +1688,7 @@ QString QDB2Driver::formatValue(const QSqlField &field, bool trimStrings) const
return QLatin1String("NULL");
switch (field.metaType().id()) {
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
// Use an escape sequence for the datetime fields
if (field.value().toDateTime().isValid()) {
QDate dt = field.value().toDateTime().date();
@@ -1708,7 +1708,7 @@ QString QDB2Driver::formatValue(const QSqlField &field, bool trimStrings) const
return QLatin1String("NULL");
}
}
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
QByteArray ba = field.value().toByteArray();
QString res;
res += QLatin1String("BLOB(X'");
diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
index 7be2df6dd9..b61c41735b 100644
--- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
@@ -158,7 +158,7 @@ static void delDA(XSQLDA *&sqlda)
sqlda = 0;
}
-static QVariant::Type qIBaseTypeName(int iType, bool hasScale)
+static int qIBaseTypeName(int iType, bool hasScale)
{
switch (iType) {
case blr_varying:
@@ -166,60 +166,60 @@ static QVariant::Type qIBaseTypeName(int iType, bool hasScale)
case blr_text:
case blr_cstring:
case blr_cstring2:
- return QVariant::String;
+ return QMetaType::QString;
case blr_sql_time:
- return QVariant::Time;
+ return QMetaType::QTime;
case blr_sql_date:
- return QVariant::Date;
+ return QMetaType::QDate;
case blr_timestamp:
- return QVariant::DateTime;
+ return QMetaType::QDateTime;
case blr_blob:
- return QVariant::ByteArray;
+ return QMetaType::QByteArray;
case blr_quad:
case blr_short:
case blr_long:
- return (hasScale ? QVariant::Double : QVariant::Int);
+ return (hasScale ? QMetaType::Double : QMetaType::Int);
case blr_int64:
- return (hasScale ? QVariant::Double : QVariant::LongLong);
+ return (hasScale ? QMetaType::Double : QMetaType::LongLong);
case blr_float:
case blr_d_float:
case blr_double:
- return QVariant::Double;
+ return QMetaType::Double;
case blr_boolean_dtype:
- return QVariant::Bool;
+ return QMetaType::Bool;
}
qWarning("qIBaseTypeName: unknown datatype: %d", iType);
- return QVariant::Invalid;
+ return QMetaType::UnknownType;
}
-static QVariant::Type qIBaseTypeName2(int iType, bool hasScale)
+static int qIBaseTypeName2(int iType, bool hasScale)
{
switch(iType & ~1) {
case SQL_VARYING:
case SQL_TEXT:
- return QVariant::String;
+ return QMetaType::QString;
case SQL_LONG:
case SQL_SHORT:
- return (hasScale ? QVariant::Double : QVariant::Int);
+ return (hasScale ? QMetaType::Double : QMetaType::Int);
case SQL_INT64:
- return (hasScale ? QVariant::Double : QVariant::LongLong);
+ return (hasScale ? QMetaType::Double : QMetaType::LongLong);
case SQL_FLOAT:
case SQL_DOUBLE:
- return QVariant::Double;
+ return QMetaType::Double;
case SQL_TIMESTAMP:
- return QVariant::DateTime;
+ return QMetaType::QDateTime;
case SQL_TYPE_TIME:
- return QVariant::Time;
+ return QMetaType::QTime;
case SQL_TYPE_DATE:
- return QVariant::Date;
+ return QMetaType::QDate;
case SQL_ARRAY:
- return QVariant::List;
+ return QMetaType::QVariantList;
case SQL_BLOB:
- return QVariant::ByteArray;
+ return QMetaType::QByteArray;
case SQL_BOOLEAN:
- return QVariant::Bool;
+ return QMetaType::Bool;
default:
- return QVariant::Invalid;
+ return QMetaType::UnknownType;
}
}
@@ -674,7 +674,7 @@ static char* qFillBufferWithString(char *buffer, const QString& string,
}
static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
- QVariant::Type type, short curDim, ISC_ARRAY_DESC *arrayDesc,
+ int type, short curDim, ISC_ARRAY_DESC *arrayDesc,
QString& error)
{
int i;
@@ -694,7 +694,7 @@ static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
if (curDim != dim) {
for(i = 0; i < list.size(); ++i) {
- if (list.at(i).userType() != QVariant::List) { // dimensions mismatch
+ if (list.at(i).typeId() != QMetaType::QVariantList) { // dimensions mismatch
error = QLatin1String("Array dimensons mismatch. Fieldname: %1");
return 0;
}
@@ -706,52 +706,52 @@ static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
}
} else {
switch(type) {
- case QVariant::Int:
- case QVariant::UInt:
+ case QMetaType::Int:
+ case QMetaType::UInt:
if (arrayDesc->array_desc_dtype == blr_short)
buffer = fillList<short>(buffer, list);
else
buffer = fillList<int>(buffer, list);
break;
- case QVariant::Double:
+ case QMetaType::Double:
if (arrayDesc->array_desc_dtype == blr_float)
buffer = fillList<float>(buffer, list, static_cast<float *>(0));
else
buffer = fillList<double>(buffer, list);
break;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
buffer = fillList<qint64>(buffer, list);
break;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
buffer = fillList<quint64>(buffer, list);
break;
- case QVariant::String:
+ case QMetaType::QString:
for (i = 0; i < list.size(); ++i)
buffer = qFillBufferWithString(buffer, list.at(i).toString(),
arrayDesc->array_desc_length,
arrayDesc->array_desc_dtype == blr_varying,
true);
break;
- case QVariant::Date:
+ case QMetaType::QDate:
for (i = 0; i < list.size(); ++i) {
*((ISC_DATE*)buffer) = toDate(list.at(i).toDate());
buffer += sizeof(ISC_DATE);
}
break;
- case QVariant::Time:
+ case QMetaType::QTime:
for (i = 0; i < list.size(); ++i) {
*((ISC_TIME*)buffer) = toTime(list.at(i).toTime());
buffer += sizeof(ISC_TIME);
}
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
for (i = 0; i < list.size(); ++i) {
*((ISC_TIMESTAMP*)buffer) = toTimeStamp(list.at(i).toDateTime());
buffer += sizeof(ISC_TIMESTAMP);
}
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
buffer = fillList<bool>(buffer, list);
break;
default:
@@ -1132,16 +1132,16 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
// null value
QVariant v;
v.convert(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype, d->sqlda->sqlvar[i].sqlscale < 0));
- if (v.userType() == QVariant::Double) {
+ if (v.userType() == QMetaType::Double) {
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
- v.convert(QVariant::Int);
+ v.convert(QMetaType::Int);
break;
case QSql::LowPrecisionInt64:
- v.convert(QVariant::LongLong);
+ v.convert(QMetaType::LongLong);
break;
case QSql::HighPrecision:
- v.convert(QVariant::String);
+ v.convert(QMetaType::QString);
break;
case QSql::LowPrecisionDouble:
// no conversion
@@ -1214,19 +1214,19 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
QVariant v = row[idx];
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
- if(v.convert(QVariant::Int))
+ if (v.convert(QMetaType::Int))
row[idx]=v;
break;
case QSql::LowPrecisionInt64:
- if(v.convert(QVariant::LongLong))
+ if (v.convert(QMetaType::LongLong))
row[idx]=v;
break;
case QSql::LowPrecisionDouble:
- if(v.convert(QVariant::Double))
+ if (v.convert(QMetaType::Double))
row[idx]=v;
break;
case QSql::HighPrecision:
- if(v.convert(QVariant::String))
+ if (v.convert(QMetaType::QString))
row[idx]=v;
break;
}
@@ -1695,7 +1695,7 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const
QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) const
{
switch (field.type()) {
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QDateTime datetime = field.value().toDateTime();
if (datetime.isValid())
return QLatin1Char('\'') + QString::number(datetime.date().year()) + QLatin1Char('-') +
@@ -1709,7 +1709,7 @@ QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) cons
else
return QLatin1String("NULL");
}
- case QVariant::Time: {
+ case QMetaType::QTime: {
QTime time = field.value().toTime();
if (time.isValid())
return QLatin1Char('\'') + QString::number(time.hour()) + QLatin1Char(':') +
@@ -1720,7 +1720,7 @@ QString QIBaseDriver::formatValue(const QSqlField &field, bool trimStrings) cons
else
return QLatin1String("NULL");
}
- case QVariant::Date: {
+ case QMetaType::QDate: {
QDate date = field.value().toDate();
if (date.isValid())
return QLatin1Char('\'') + QString::number(date.year()) + QLatin1Char('-') +
diff --git a/src/plugins/sqldrivers/oci/qsql_oci.cpp b/src/plugins/sqldrivers/oci/qsql_oci.cpp
index 5bf9400180..28b419e6a1 100644
--- a/src/plugins/sqldrivers/oci/qsql_oci.cpp
+++ b/src/plugins/sqldrivers/oci/qsql_oci.cpp
@@ -364,8 +364,8 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
int r = OCI_SUCCESS;
void *data = const_cast<void *>(val.constData());
- switch (val.type()) {
- case QVariant::ByteArray:
+ switch (val.typeId()) {
+ case QMetaType::QByteArray:
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
isOutValue(pos)
@@ -374,9 +374,9 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
reinterpret_cast<QByteArray *>(data)->size(),
SQLT_BIN, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
- case QVariant::Time:
- case QVariant::Date:
- case QVariant::DateTime: {
+ case QMetaType::QTime:
+ case QMetaType::QDate:
+ case QMetaType::QDateTime: {
QOCIDateTime *ptr = new QOCIDateTime(env, err, val.toDateTime());
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
@@ -386,7 +386,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
tmpStorage.dateTimes.append(ptr);
break;
}
- case QVariant::Int:
+ case QMetaType::Int:
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// if it's an out value, the data is already detached
@@ -395,7 +395,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
sizeof(int),
SQLT_INT, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
- case QVariant::UInt:
+ case QMetaType::UInt:
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// if it's an out value, the data is already detached
@@ -404,7 +404,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
sizeof(uint),
SQLT_UIN, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
{
QByteArray ba = qMakeOCINumber(val.toLongLong(), err);
r = OCIBindByPos(sql, hbnd, err,
@@ -415,7 +415,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
tmpStorage.rawData.append(ba);
break;
}
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
{
QByteArray ba = qMakeOCINumber(val.toULongLong(), err);
r = OCIBindByPos(sql, hbnd, err,
@@ -426,7 +426,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
tmpStorage.rawData.append(ba);
break;
}
- case QVariant::Double:
+ case QMetaType::Double:
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// if it's an out value, the data is already detached
@@ -435,22 +435,7 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
sizeof(double),
SQLT_FLT, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
- case QVariant::UserType:
- if (val.canConvert<QOCIRowIdPointer>() && !isOutValue(pos)) {
- // use a const pointer to prevent a detach
- const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
- r = OCIBindByPos(sql, hbnd, err,
- pos + 1,
- // it's an IN value, so const_cast is ok
- const_cast<OCIRowid **>(&rptr->id),
- -1,
- SQLT_RDD, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
- } else {
- qWarning("Unknown bind variable");
- r = OCI_ERROR;
- }
- break;
- case QVariant::String: {
+ case QMetaType::QString: {
const QString s = val.toString();
if (isBinaryValue(pos)) {
r = OCIBindByPos(sql, hbnd, err,
@@ -473,27 +458,43 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
}
} // fall through for OUT values
default: {
- const QString s = val.toString();
- // create a deep-copy
- QByteArray ba(reinterpret_cast<const char *>(s.utf16()), (s.length() + 1) * sizeof(QChar));
- if (isOutValue(pos)) {
- ba.reserve((s.capacity() + 1) * sizeof(QChar));
- *tmpSize = ba.size();
- r = OCIBindByPos(sql, hbnd, err,
- pos + 1,
- ba.data(),
- ba.capacity(),
- SQLT_STR, indPtr, tmpSize, 0, 0, 0, OCI_DEFAULT);
+ if (val.typeId() >= QMetaType::User) {
+ if (val.canConvert<QOCIRowIdPointer>() && !isOutValue(pos)) {
+ // use a const pointer to prevent a detach
+ const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
+ r = OCIBindByPos(sql, hbnd, err,
+ pos + 1,
+ // it's an IN value, so const_cast is ok
+ const_cast<OCIRowid **>(&rptr->id),
+ -1,
+ SQLT_RDD, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
+ } else {
+ qWarning("Unknown bind variable");
+ r = OCI_ERROR;
+ }
} else {
- r = OCIBindByPos(sql, hbnd, err,
- pos + 1,
- ba.data(),
- ba.size(),
- SQLT_STR, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
+ const QString s = val.toString();
+ // create a deep-copy
+ QByteArray ba(reinterpret_cast<const char *>(s.utf16()), (s.length() + 1) * sizeof(QChar));
+ if (isOutValue(pos)) {
+ ba.reserve((s.capacity() + 1) * sizeof(QChar));
+ *tmpSize = ba.size();
+ r = OCIBindByPos(sql, hbnd, err,
+ pos + 1,
+ ba.data(),
+ ba.capacity(),
+ SQLT_STR, indPtr, tmpSize, 0, 0, 0, OCI_DEFAULT);
+ } else {
+ r = OCIBindByPos(sql, hbnd, err,
+ pos + 1,
+ ba.data(),
+ ba.size(),
+ SQLT_STR, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
+ }
+ if (r == OCI_SUCCESS)
+ setCharset(*hbnd, OCI_HTYPE_BIND);
+ tmpStorage.rawData.append(ba);
}
- if (r == OCI_SUCCESS)
- setCharset(*hbnd, OCI_HTYPE_BIND);
- tmpStorage.rawData.append(ba);
break;
} // default case
} // switch
@@ -523,26 +524,26 @@ int QOCIResultPrivate::bindValues(QVariantList &values, IndicatorArray &indicato
// will assign out value and remove its temp storage.
static void qOraOutValue(QVariant &value, TempStorage &tmpStorage, OCIEnv *env, OCIError* err)
{
- switch (value.type()) {
- case QVariant::Time:
+ switch (value.typeId()) {
+ case QMetaType::QTime:
value = QOCIDateTime::fromOCIDateTime(env, err,
tmpStorage.dateTimes.takeFirst()->dateTime).time();
break;
- case QVariant::Date:
+ case QMetaType::QDate:
value = QOCIDateTime::fromOCIDateTime(env, err,
tmpStorage.dateTimes.takeFirst()->dateTime).date();
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
value = QOCIDateTime::fromOCIDateTime(env, err,
tmpStorage.dateTimes.takeFirst()->dateTime);
break;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
value = qMakeLongLong(tmpStorage.rawData.takeFirst(), err);
break;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
value = qMakeULongLong(tmpStorage.rawData.takeFirst(), err);
break;
- case QVariant::String:
+ case QMetaType::String:
value = QString(
reinterpret_cast<const QChar *>(tmpStorage.rawData.takeFirst().constData()));
break;
@@ -591,7 +592,7 @@ void QOCIDriverPrivate::allocErrorHandle()
struct OraFieldInfo
{
QString name;
- QVariant::Type type;
+ QMetaType type;
ub1 oraIsNull;
ub4 oraType;
sb1 oraScale;
@@ -650,53 +651,53 @@ QSqlError qMakeError(const QString& errString, QSqlError::ErrorType type, OCIErr
errorCode != -1 ? QString::number(errorCode) : QString());
}
-QVariant::Type qDecodeOCIType(const QString& ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
+QMetaType qDecodeOCIType(const QString& ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
{
- QVariant::Type type = QVariant::Invalid;
+ int type = QMetaType::UnknownType;
if (ocitype == QLatin1String("VARCHAR2") || ocitype == QLatin1String("VARCHAR")
|| ocitype.startsWith(QLatin1String("INTERVAL"))
|| ocitype == QLatin1String("CHAR") || ocitype == QLatin1String("NVARCHAR2")
|| ocitype == QLatin1String("NCHAR"))
- type = QVariant::String;
+ type = QMetaType::QString;
else if (ocitype == QLatin1String("NUMBER")
|| ocitype == QLatin1String("FLOAT")
|| ocitype == QLatin1String("BINARY_FLOAT")
|| ocitype == QLatin1String("BINARY_DOUBLE")) {
switch(precisionPolicy) {
case QSql::LowPrecisionInt32:
- type = QVariant::Int;
+ type = QMetaType::Int;
break;
case QSql::LowPrecisionInt64:
- type = QVariant::LongLong;
+ type = QMetaType::LongLong;
break;
case QSql::LowPrecisionDouble:
- type = QVariant::Double;
+ type = QMetaType::Double;
break;
case QSql::HighPrecision:
default:
- type = QVariant::String;
+ type = QMetaType::QString;
break;
}
}
else if (ocitype == QLatin1String("LONG") || ocitype == QLatin1String("NCLOB")
|| ocitype == QLatin1String("CLOB"))
- type = QVariant::ByteArray;
+ type = QMetaType::QByteArray;
else if (ocitype == QLatin1String("RAW") || ocitype == QLatin1String("LONG RAW")
|| ocitype == QLatin1String("ROWID") || ocitype == QLatin1String("BLOB")
|| ocitype == QLatin1String("CFILE") || ocitype == QLatin1String("BFILE"))
- type = QVariant::ByteArray;
+ type = QMetaType::QByteArray;
else if (ocitype == QLatin1String("DATE") || ocitype.startsWith(QLatin1String("TIME")))
- type = QVariant::DateTime;
+ type = QMetaType::QDateTime;
else if (ocitype == QLatin1String("UNDEFINED"))
- type = QVariant::Invalid;
- if (type == QVariant::Invalid)
+ type = QMetaType::UnknownType;
+ if (type == QMetaType::UnknownType)
qWarning("qDecodeOCIType: unknown type: %s", ocitype.toLocal8Bit().constData());
- return type;
+ return QMetaType(type);
}
-QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
+QMetaType qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precisionPolicy)
{
- QVariant::Type type = QVariant::Invalid;
+ int type = QMetaType::UnknownType;
switch (ocitype) {
case SQLT_STR:
case SQLT_VST:
@@ -712,10 +713,10 @@ QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precis
#ifdef SQLT_INTERVAL_DS
case SQLT_INTERVAL_DS:
#endif
- type = QVariant::String;
+ type = QMetaType::QString;
break;
case SQLT_INT:
- type = QVariant::Int;
+ type = QMetaType::Int;
break;
case SQLT_FLT:
case SQLT_NUM:
@@ -723,17 +724,17 @@ QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precis
case SQLT_UIN:
switch(precisionPolicy) {
case QSql::LowPrecisionInt32:
- type = QVariant::Int;
+ type = QMetaType::Int;
break;
case QSql::LowPrecisionInt64:
- type = QVariant::LongLong;
+ type = QMetaType::LongLong;
break;
case QSql::LowPrecisionDouble:
- type = QVariant::Double;
+ type = QMetaType::Double;
break;
case QSql::HighPrecision:
default:
- type = QVariant::String;
+ type = QMetaType::QString;
break;
}
break;
@@ -748,21 +749,20 @@ QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precis
case SQLT_NTY:
case SQLT_REF:
case SQLT_RID:
- type = QVariant::ByteArray;
+ type = QMetaType::QByteArray;
break;
case SQLT_DAT:
case SQLT_ODT:
case SQLT_TIMESTAMP:
case SQLT_TIMESTAMP_TZ:
case SQLT_TIMESTAMP_LTZ:
- type = QVariant::DateTime;
+ type = QMetaType::QDateTime;
break;
default:
- type = QVariant::Invalid;
qWarning("qDecodeOCIType: unknown OCI datatype: %d", ocitype);
break;
}
- return type;
+ return QMetaType(type);
}
static QSqlField qFromOraInf(const OraFieldInfo &ofi)
@@ -770,7 +770,7 @@ static QSqlField qFromOraInf(const OraFieldInfo &ofi)
QSqlField f(ofi.name, ofi.type);
f.setRequired(ofi.oraIsNull == 0);
- if (ofi.type == QVariant::String && ofi.oraType != SQLT_NUM && ofi.oraType != SQLT_VNU)
+ if (ofi.type.id() == QMetaType::QString && ofi.oraType != SQLT_NUM && ofi.oraType != SQLT_VNU)
f.setLength(ofi.oraFieldLength);
else
f.setLength(ofi.oraPrecision == 0 ? 38 : int(ofi.oraPrecision));
@@ -852,13 +852,13 @@ private:
class OraFieldInf
{
public:
- OraFieldInf() : data(0), len(0), ind(0), typ(QVariant::Invalid), oraType(0), def(0), lob(0), dataPtr(nullptr)
+ OraFieldInf() : data(0), len(0), ind(0), oraType(0), def(0), lob(0), dataPtr(nullptr)
{}
~OraFieldInf();
char *data;
int len;
sb2 ind;
- QVariant::Type typ;
+ QMetaType typ;
ub4 oraType;
OCIDefine *def;
OCILobLocator *lob;
@@ -879,9 +879,9 @@ QOCICols::OraFieldInf::~OraFieldInf()
}
if (dataPtr) {
switch (typ) {
- case QVariant::Date:
- case QVariant::Time:
- case QVariant::DateTime: {
+ case QMetaType::QDate:
+ case QMetaType::QTime:
+ case QMetaType::QDateTime: {
int r = OCIDescriptorFree(dataPtr, OCI_DTYPE_TIMESTAMP_TZ);
if (r != OCI_SUCCESS)
qWarning("QOCICols: Cannot free OCIDateTime descriptor");
@@ -935,8 +935,8 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
fieldInf[idx].oraType = ofi.oraType;
rec.append(qFromOraInf(ofi));
- switch (ofi.type) {
- case QVariant::DateTime:
+ switch (ofi.type.id()) {
+ case QMetaType::QDateTime:
r = OCIDescriptorAlloc(d->env, (void **)&fieldInf[idx].dataPtr, OCI_DTYPE_TIMESTAMP_TZ, 0, 0);
if (r != OCI_SUCCESS) {
qWarning("QOCICols: Unable to allocate the OCIDateTime descriptor");
@@ -952,7 +952,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
&(fieldInf[idx].ind),
0, 0, OCI_DEFAULT);
break;
- case QVariant::Double:
+ case QMetaType::Double:
r = OCIDefineByPos(d->sql,
&dfn,
d->err,
@@ -963,7 +963,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
&(fieldInf[idx].ind),
0, 0, OCI_DEFAULT);
break;
- case QVariant::Int:
+ case QMetaType::Int:
r = OCIDefineByPos(d->sql,
&dfn,
d->err,
@@ -974,7 +974,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
&(fieldInf[idx].ind),
0, 0, OCI_DEFAULT);
break;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
r = OCIDefineByPos(d->sql,
&dfn,
d->err,
@@ -985,7 +985,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
&(fieldInf[idx].ind),
0, 0, OCI_DEFAULT);
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
// RAW and LONG RAW fields can't be bound to LOB locators
if (ofi.oraType == SQLT_BIN) {
// qDebug("binding SQLT_BIN");
@@ -1032,7 +1032,7 @@ QOCICols::QOCICols(int size, QOCIResultPrivate* dp)
0, 0, OCI_DEFAULT);
}
break;
- case QVariant::String:
+ case QMetaType::QString:
if (ofi.oraType == SQLT_LNG) {
r = OCIDefineByPos(d->sql,
&dfn,
@@ -1192,7 +1192,6 @@ OraFieldInfo QOCICols::qMakeOraField(const QOCIResultPrivate* p, OCIParam* param
sb2 colPrecision(0);
ub1 colIsNull(0);
int r(0);
- QVariant::Type type(QVariant::Invalid);
r = OCIAttrGet(param,
OCI_DTYPE_PARAM,
@@ -1269,28 +1268,26 @@ OraFieldInfo QOCICols::qMakeOraField(const QOCIResultPrivate* p, OCIParam* param
if (r != 0)
qOraWarning("qMakeOraField:", p->err);
- type = qDecodeOCIType(colType, p->q_func()->numericalPrecisionPolicy());
+ QMetaType type = qDecodeOCIType(colType, p->q_func()->numericalPrecisionPolicy());
- if (type == QVariant::Int) {
- if (colLength == 22 && colPrecision == 0 && colScale == 0)
- type = QVariant::String;
- if (colScale > 0)
- type = QVariant::String;
+ if (type.id() == QMetaType::Int) {
+ if ((colLength == 22 && colPrecision == 0 && colScale == 0) || colScale > 0)
+ type = QMetaType(QMetaType::QString);
}
// bind as double if the precision policy asks for it
if (((colType == SQLT_FLT) || (colType == SQLT_NUM))
&& (p->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionDouble)) {
- type = QVariant::Double;
+ type = QMetaType(QMetaType::Double);
}
// bind as int32 or int64 if the precision policy asks for it
if ((colType == SQLT_NUM) || (colType == SQLT_VNU) || (colType == SQLT_UIN)
|| (colType == SQLT_INT)) {
if (p->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionInt64)
- type = QVariant::LongLong;
+ type = QMetaType(QMetaType::LongLong);
else if (p->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionInt32)
- type = QVariant::Int;
+ type = QMetaType(QMetaType::Int);
}
if (colType == SQLT_BLOB)
@@ -1357,11 +1354,10 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
int i;
sword r;
- QVarLengthArray<QVariant::Type> fieldTypes;
+ QVarLengthArray<QMetaType> fieldTypes;
for (i = 0; i < columnCount; ++i) {
- QVariant::Type tp = boundValues.at(i).type();
- fieldTypes.append(tp == QVariant::List ? boundValues.at(i).toList().value(0).type()
- : tp);
+ QMetaType tp = boundValues.at(i).metaType();
+ fieldTypes.append(tp.id() == QMetaType::QVariantList ? boundValues.at(i).toList().value(0).metaType() : tp);
}
SizeArray tmpSizes(columnCount);
QList<QOCIBatchColumn> columns(columnCount);
@@ -1371,7 +1367,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
// figuring out buffer sizes
for (i = 0; i < columnCount; ++i) {
- if (boundValues.at(i).type() != QVariant::List) {
+ if (boundValues.at(i).typeId() != QMetaType::QVariantList) {
// not a list - create a deep-copy of the single value
QOCIBatchColumn &singleCol = columns[i];
@@ -1399,45 +1395,40 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
col.maxarr_len = col.recordCount;
col.curelep = col.recordCount;
- switch (fieldTypes[i]) {
- case QVariant::Time:
- case QVariant::Date:
- case QVariant::DateTime:
+ switch (fieldTypes[i].id()) {
+ case QMetaType::QTime:
+ case QMetaType::QDate:
+ case QMetaType::QDateTime:
col.bindAs = SQLT_TIMESTAMP_TZ;
col.maxLen = sizeof(OCIDateTime *);
break;
- case QVariant::Int:
+ case QMetaType::Int:
col.bindAs = SQLT_INT;
col.maxLen = sizeof(int);
break;
- case QVariant::UInt:
+ case QMetaType::UInt:
col.bindAs = SQLT_UIN;
col.maxLen = sizeof(uint);
break;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
col.bindAs = SQLT_VNU;
col.maxLen = sizeof(OCINumber);
break;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
col.bindAs = SQLT_VNU;
col.maxLen = sizeof(OCINumber);
break;
- case QVariant::Double:
+ case QMetaType::Double:
col.bindAs = SQLT_FLT;
col.maxLen = sizeof(double);
break;
- case QVariant::UserType:
- col.bindAs = SQLT_RDD;
- col.maxLen = sizeof(OCIRowid*);
- break;
-
- case QVariant::String: {
+ case QMetaType::QString: {
col.bindAs = SQLT_STR;
for (uint j = 0; j < col.recordCount; ++j) {
uint len;
@@ -1451,18 +1442,23 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
col.maxLen *= sizeof(QChar);
break; }
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
default: {
- col.bindAs = SQLT_LBI;
- for (uint j = 0; j < col.recordCount; ++j) {
- if(d->isOutValue(i))
- col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().capacity();
- else
- col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().size();
- if (col.lengths[j] > col.maxLen)
- col.maxLen = col.lengths[j];
+ if (fieldTypes[i].typeId() >= QMetaType::User) {
+ col.bindAs = SQLT_RDD;
+ col.maxLen = sizeof(OCIRowid*);
+ } else {
+ col.bindAs = SQLT_LBI;
+ for (uint j = 0; j < col.recordCount; ++j) {
+ if (d->isOutValue(i))
+ col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().capacity();
+ else
+ col.lengths[j] = boundValues.at(i).toList().at(j).toByteArray().size();
+ if (col.lengths[j] > col.maxLen)
+ col.maxLen = col.lengths[j];
+ }
}
- break; }
+ break;
}
col.data = new char[col.maxLen * col.recordCount];
@@ -1478,26 +1474,26 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
} else {
columns[i].indicators[row] = 0;
char *dataPtr = columns[i].data + (columns[i].maxLen * row);
- switch (fieldTypes[i]) {
- case QVariant::Time:
- case QVariant::Date:
- case QVariant::DateTime:{
+ switch (fieldTypes[i].id()) {
+ case QMetaType::QTime:
+ case QMetaType::QDate:
+ case QMetaType::QDateTime:{
columns[i].lengths[row] = columns[i].maxLen;
QOCIDateTime *date = new QOCIDateTime(d->env, d->err, val.toDateTime());
*reinterpret_cast<OCIDateTime**>(dataPtr) = date->dateTime;
break;
}
- case QVariant::Int:
+ case QMetaType::Int:
columns[i].lengths[row] = columns[i].maxLen;
*reinterpret_cast<int*>(dataPtr) = val.toInt();
break;
- case QVariant::UInt:
+ case QMetaType::UInt:
columns[i].lengths[row] = columns[i].maxLen;
*reinterpret_cast<uint*>(dataPtr) = val.toUInt();
break;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
{
columns[i].lengths[row] = columns[i].maxLen;
const QByteArray ba = qMakeOCINumber(val.toLongLong(), d->err);
@@ -1505,7 +1501,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
memcpy(dataPtr, ba.constData(), columns[i].maxLen);
break;
}
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
{
columns[i].lengths[row] = columns[i].maxLen;
const QByteArray ba = qMakeOCINumber(val.toULongLong(), d->err);
@@ -1513,29 +1509,31 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
memcpy(dataPtr, ba.constData(), columns[i].maxLen);
break;
}
- case QVariant::Double:
+ case QMetaType::Double:
columns[i].lengths[row] = columns[i].maxLen;
*reinterpret_cast<double*>(dataPtr) = val.toDouble();
break;
- case QVariant::String: {
+ case QMetaType::QString: {
const QString s = val.toString();
columns[i].lengths[row] = (s.length() + 1) * sizeof(QChar);
memcpy(dataPtr, s.utf16(), columns[i].lengths[row]);
break;
}
- case QVariant::UserType:
- if (val.canConvert<QOCIRowIdPointer>()) {
- const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
- *reinterpret_cast<OCIRowid**>(dataPtr) = rptr->id;
- columns[i].lengths[row] = 0;
- break;
- }
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
default: {
- const QByteArray ba = val.toByteArray();
- columns[i].lengths[row] = ba.size();
- memcpy(dataPtr, ba.constData(), ba.size());
+ if (fieldTypes[i].id() >= QMetaType::User) {
+ if (val.canConvert<QOCIRowIdPointer>()) {
+ const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
+ *reinterpret_cast<OCIRowid**>(dataPtr) = rptr->id;
+ columns[i].lengths[row] = 0;
+ break;
+ }
+ } else {
+ const QByteArray ba = val.toByteArray();
+ columns[i].lengths[row] = ba.size();
+ memcpy(dataPtr, ba.constData(), ba.size());
+ }
break;
}
}
@@ -1618,7 +1616,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
if (!d->isOutValue(i))
continue;
- if (auto tp = boundValues.at(i).metaType(); tp.id() != QVariant::List) {
+ if (auto tp = boundValues.at(i).metaType(); tp.id() != QMetaType::QVariantList) {
qOraOutValue(boundValues[i], tmpStorage, d->env, d->err);
if (*columns[i].indicators == -1)
boundValues[i] = QVariant(tp);
@@ -1651,11 +1649,11 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVariantList &boundValues, bool a
case SQLT_VNU:
{
- switch (boundValues.at(i).type()) {
- case QVariant::LongLong:
+ switch (boundValues.at(i).typeId()) {
+ case QMetaType::LongLong:
(*list)[r] = qMakeLongLong(data + r * columns[i].maxLen, d->err);
break;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
(*list)[r] = qMakeULongLong(data + r * columns[i].maxLen, d->err);
break;
default:
@@ -1791,21 +1789,21 @@ void QOCICols::getValues(QVariantList &v, int index)
if (fld.oraType == SQLT_BIN || fld.oraType == SQLT_LBI || fld.oraType == SQLT_LNG)
continue; // already fetched piecewise
- switch (fld.typ) {
- case QVariant::DateTime:
+ switch (fld.typ.id()) {
+ case QMetaType::QDateTime:
v[index + i] = QVariant(QOCIDateTime::fromOCIDateTime(d->env, d->err,
reinterpret_cast<OCIDateTime *>(fld.dataPtr)));
break;
- case QVariant::Double:
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Double:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
if (d->q_func()->numericalPrecisionPolicy() != QSql::HighPrecision) {
if ((d->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionDouble)
- && (fld.typ == QVariant::Double)) {
+ && (fld.typ.id() == QMetaType::Double)) {
v[index + i] = *reinterpret_cast<double *>(fld.data);
break;
} else if ((d->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionInt64)
- && (fld.typ == QVariant::LongLong)) {
+ && (fld.typ.id() == QMetaType::LongLong)) {
qint64 qll = 0;
int r = OCINumberToInt(d->err, reinterpret_cast<OCINumber *>(fld.data), sizeof(qint64),
OCI_NUMBER_SIGNED, &qll);
@@ -1815,20 +1813,20 @@ void QOCICols::getValues(QVariantList &v, int index)
v[index + i] = QVariant();
break;
} else if ((d->q_func()->numericalPrecisionPolicy() == QSql::LowPrecisionInt32)
- && (fld.typ == QVariant::Int)) {
+ && (fld.typ.id() == QMetaType::Int)) {
v[index + i] = *reinterpret_cast<int *>(fld.data);
break;
}
}
// else fall through
- case QVariant::String:
+ case QMetaType::QString:
v[index + i] = QString(reinterpret_cast<const QChar *>(fld.data));
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
if (fld.len > 0)
v[index + i] = QByteArray(fld.data, fld.len);
else
- v[index + i] = QVariant(QVariant::ByteArray);
+ v[index + i] = QVariant(QMetaType::QByteArray);
break;
default:
qWarning("QOCICols::value: unknown data type");
@@ -2617,11 +2615,11 @@ QSqlRecord QOCIDriver::record(const QString& tablename) const
<< QLatin1String("BINARY_DOUBLE");
if (buildRecordInfo) {
do {
- QVariant::Type ty = qDecodeOCIType(t.value(1).toString(), t.numericalPrecisionPolicy());
+ QMetaType ty = qDecodeOCIType(t.value(1).toString(), t.numericalPrecisionPolicy());
QSqlField f(t.value(0).toString(), ty);
f.setRequired(t.value(5).toString() == QLatin1String("N"));
f.setPrecision(t.value(4).toInt());
- if (d->serverVersion >= 9 && (ty == QVariant::String) && !t.isNull(3) && !keywords.contains(t.value(1).toString())) {
+ if (d->serverVersion >= 9 && (ty.id() == QMetaType::QString) && !t.isNull(3) && !keywords.contains(t.value(1).toString())) {
// Oracle9: data_length == size in bytes, char_length == amount of characters
f.setLength(t.value(7).toInt());
} else {
@@ -2704,8 +2702,8 @@ QSqlIndex QOCIDriver::primaryIndex(const QString& tablename) const
QString QOCIDriver::formatValue(const QSqlField &field, bool trimStrings) const
{
- switch (field.type()) {
- case QVariant::DateTime: {
+ switch (field.typeId()) {
+ case QMetaType::QDateTime: {
QDateTime datetime = field.value().toDateTime();
QString datestring;
if (datetime.isValid()) {
@@ -2722,7 +2720,7 @@ QString QOCIDriver::formatValue(const QSqlField &field, bool trimStrings) const
}
return datestring;
}
- case QVariant::Time: {
+ case QMetaType::QTime: {
QDateTime datetime = field.value().toDateTime();
QString datestring;
if (datetime.isValid()) {
@@ -2736,7 +2734,7 @@ QString QOCIDriver::formatValue(const QSqlField &field, bool trimStrings) const
}
return datestring;
}
- case QVariant::Date: {
+ case QMetaType::QDate: {
QDate date = field.value().toDate();
QString datestring;
if (date.isValid()) {
diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index 5a00a000f7..27766c6a95 100644
--- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
@@ -554,7 +554,7 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column)
if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO)
break;
if (lengthIndicator == SQL_NULL_DATA)
- return QVariant(QMetaType(QVariant::ByteArray));
+ return QVariant(QMetaType(QMetaType::QByteArray));
if (lengthIndicator > SQLLEN(colSize) || lengthIndicator == SQL_NO_TOTAL) {
read += colSize;
colSize = 65536;
@@ -1213,19 +1213,19 @@ QVariant QODBCResult::data(int field)
// fetched column n+1, so cache all previous columns here
const QSqlField info = d->rInf.field(i);
switch (info.metaType().id()) {
- case QVariant::LongLong:
+ case QMetaType::LongLong:
d->fieldCache[i] = qGetBigIntData(d->hStmt, i);
break;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
d->fieldCache[i] = qGetBigIntData(d->hStmt, i, false);
break;
- case QVariant::Int:
+ case QMetaType::Int:
d->fieldCache[i] = qGetIntData(d->hStmt, i);
break;
- case QVariant::UInt:
+ case QMetaType::UInt:
d->fieldCache[i] = qGetIntData(d->hStmt, i, false);
break;
- case QVariant::Date:
+ case QMetaType::QDate:
DATE_STRUCT dbuf;
r = SQLGetData(d->hStmt,
i + 1,
@@ -1238,7 +1238,7 @@ QVariant QODBCResult::data(int field)
else
d->fieldCache[i] = QVariant(QMetaType::fromType<QDate>());
break;
- case QVariant::Time:
+ case QMetaType::QTime:
TIME_STRUCT tbuf;
r = SQLGetData(d->hStmt,
i + 1,
@@ -1251,7 +1251,7 @@ QVariant QODBCResult::data(int field)
else
d->fieldCache[i] = QVariant(QMetaType::fromType<QTime>());
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
TIMESTAMP_STRUCT dtbuf;
r = SQLGetData(d->hStmt,
i + 1,
@@ -1265,13 +1265,13 @@ QVariant QODBCResult::data(int field)
else
d->fieldCache[i] = QVariant(QMetaType::fromType<QDateTime>());
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
d->fieldCache[i] = qGetBinaryData(d->hStmt, i);
break;
- case QVariant::String:
+ case QMetaType::QString:
d->fieldCache[i] = qGetStringData(d->hStmt, i, info.length(), d->unicode);
break;
- case QVariant::Double:
+ case QMetaType::Double:
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
d->fieldCache[i] = qGetIntData(d->hStmt, i);
@@ -1414,8 +1414,8 @@ bool QODBCResult::exec()
SQLLEN *ind = &indicators[i];
if (val.isNull())
*ind = SQL_NULL_DATA;
- switch (val.userType()) {
- case QVariant::Date: {
+ switch (val.typeId()) {
+ case QMetaType::QDate: {
QByteArray &ba = tmpStorage[i];
ba.resize(sizeof(DATE_STRUCT));
DATE_STRUCT *dt = (DATE_STRUCT *)const_cast<char *>(ba.constData());
@@ -1434,7 +1434,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break; }
- case QVariant::Time: {
+ case QMetaType::QTime: {
QByteArray &ba = tmpStorage[i];
ba.resize(sizeof(TIME_STRUCT));
TIME_STRUCT *dt = (TIME_STRUCT *)const_cast<char *>(ba.constData());
@@ -1453,7 +1453,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break; }
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QByteArray &ba = tmpStorage[i];
ba.resize(sizeof(TIMESTAMP_STRUCT));
TIMESTAMP_STRUCT *dt = reinterpret_cast<TIMESTAMP_STRUCT *>(const_cast<char *>(ba.constData()));
@@ -1489,7 +1489,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break; }
- case QVariant::Int:
+ case QMetaType::Int:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@@ -1501,7 +1501,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
- case QVariant::UInt:
+ case QMetaType::UInt:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@@ -1513,7 +1513,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
- case QVariant::Double:
+ case QMetaType::Double:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@@ -1525,7 +1525,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@@ -1537,7 +1537,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@@ -1549,7 +1549,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
if (*ind != SQL_NULL_DATA) {
*ind = val.toByteArray().size();
}
@@ -1564,7 +1564,7 @@ bool QODBCResult::exec()
val.toByteArray().size(),
ind);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
r = SQLBindParameter(d->hStmt,
i + 1,
qParamType[bindValueType(i) & QSql::InOut],
@@ -1576,7 +1576,7 @@ bool QODBCResult::exec()
0,
*ind == SQL_NULL_DATA ? ind : NULL);
break;
- case QVariant::String:
+ case QMetaType::QString:
if (d->unicode) {
QByteArray &ba = tmpStorage[i];
QString str = val.toString();
@@ -1689,31 +1689,31 @@ bool QODBCResult::exec()
return true;
for (i = 0; i < values.count(); ++i) {
- switch (values.at(i).userType()) {
- case QVariant::Date: {
+ switch (values.at(i).typeId()) {
+ case QMetaType::QDate: {
DATE_STRUCT ds = *((DATE_STRUCT *)const_cast<char *>(tmpStorage.at(i).constData()));
values[i] = QVariant(QDate(ds.year, ds.month, ds.day));
break; }
- case QVariant::Time: {
+ case QMetaType::QTime: {
TIME_STRUCT dt = *((TIME_STRUCT *)const_cast<char *>(tmpStorage.at(i).constData()));
values[i] = QVariant(QTime(dt.hour, dt.minute, dt.second));
break; }
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
TIMESTAMP_STRUCT dt = *((TIMESTAMP_STRUCT*)
const_cast<char *>(tmpStorage.at(i).constData()));
values[i] = QVariant(QDateTime(QDate(dt.year, dt.month, dt.day),
QTime(dt.hour, dt.minute, dt.second, dt.fraction / 1000000)));
break; }
- case QVariant::Bool:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::Double:
- case QVariant::ByteArray:
- case QVariant::LongLong:
- case QVariant::ULongLong:
+ case QMetaType::Bool:
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ case QMetaType::Double:
+ case QMetaType::QByteArray:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
//nothing to do
break;
- case QVariant::String:
+ case QMetaType::QString:
if (d->unicode) {
if (bindValueType(i) & QSql::Out) {
const QByteArray &first = tmpStorage.at(i);
@@ -2583,7 +2583,7 @@ QString QODBCDriver::formatValue(const QSqlField &field,
QString r;
if (field.isNull()) {
r = QLatin1String("NULL");
- } else if (field.metaType().id() == QVariant::DateTime) {
+ } else if (field.metaType().id() == QMetaType::QDateTime) {
// Use an escape sequence for the datetime fields
if (field.value().toDateTime().isValid()){
QDate dt = field.value().toDateTime().date();
@@ -2599,7 +2599,7 @@ QString QODBCDriver::formatValue(const QSqlField &field,
QLatin1String("' }");
} else
r = QLatin1String("NULL");
- } else if (field.metaType().id() == QVariant::ByteArray) {
+ } else if (field.metaType().id() == QMetaType::QByteArray) {
QByteArray ba = field.value().toByteArray();
QString res;
static const char hexchars[] = "0123456789abcdef";
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index cdc4ce7c36..e928f02ff4 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql.cpp
+++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp
@@ -364,15 +364,15 @@ bool QPSQLResultPrivate::processResults()
return false;
}
-static QVariant::Type qDecodePSQLType(int t)
+static QMetaType qDecodePSQLType(int t)
{
- QVariant::Type type = QVariant::Invalid;
+ int type = QMetaType::UnknownType;
switch (t) {
case QBOOLOID:
- type = QVariant::Bool;
+ type = QMetaType::Bool;
break;
case QINT8OID:
- type = QVariant::LongLong;
+ type = QMetaType::LongLong;
break;
case QINT2OID:
case QINT4OID:
@@ -380,34 +380,34 @@ static QVariant::Type qDecodePSQLType(int t)
case QREGPROCOID:
case QXIDOID:
case QCIDOID:
- type = QVariant::Int;
+ type = QMetaType::Int;
break;
case QNUMERICOID:
case QFLOAT4OID:
case QFLOAT8OID:
- type = QVariant::Double;
+ type = QMetaType::Double;
break;
case QABSTIMEOID:
case QRELTIMEOID:
case QDATEOID:
- type = QVariant::Date;
+ type = QMetaType::QDate;
break;
case QTIMEOID:
case QTIMETZOID:
- type = QVariant::Time;
+ type = QMetaType::QTime;
break;
case QTIMESTAMPOID:
case QTIMESTAMPTZOID:
- type = QVariant::DateTime;
+ type = QMetaType::QDateTime;
break;
case QBYTEAOID:
- type = QVariant::ByteArray;
+ type = QMetaType::QByteArray;
break;
default:
- type = QVariant::String;
+ type = QMetaType::QString;
break;
}
- return type;
+ return QMetaType(type);
}
void QPSQLResultPrivate::deallocatePreparedStmt()
@@ -632,23 +632,23 @@ QVariant QPSQLResult::data(int i)
}
const int currentRow = isForwardOnly() ? 0 : at();
int ptype = PQftype(d->result, i);
- QVariant::Type type = qDecodePSQLType(ptype);
+ QMetaType type = qDecodePSQLType(ptype);
if (PQgetisnull(d->result, currentRow, i))
- return QVariant(QMetaType(type), nullptr);
+ return QVariant(type, nullptr);
const char *val = PQgetvalue(d->result, currentRow, i);
- switch (type) {
- case QVariant::Bool:
+ switch (type.id()) {
+ case QMetaType::Bool:
return QVariant((bool)(val[0] == 't'));
- case QVariant::String:
+ case QMetaType::QString:
return d->drv_d_func()->isUtf8 ? QString::fromUtf8(val) : QString::fromLatin1(val);
- case QVariant::LongLong:
+ case QMetaType::LongLong:
if (val[0] == '-')
return QByteArray::fromRawData(val, qstrlen(val)).toLongLong();
else
return QByteArray::fromRawData(val, qstrlen(val)).toULongLong();
- case QVariant::Int:
+ case QMetaType::Int:
return atoi(val);
- case QVariant::Double: {
+ case QMetaType::Double: {
if (ptype == QNUMERICOID) {
if (numericalPrecisionPolicy() == QSql::HighPrecision)
return QString::fromLatin1(val);
@@ -675,26 +675,26 @@ QVariant QPSQLResult::data(int i)
}
return dbl;
}
- case QVariant::Date:
+ case QMetaType::QDate:
#if QT_CONFIG(datestring)
return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate));
#else
return QVariant(QString::fromLatin1(val));
#endif
- case QVariant::Time:
+ case QMetaType::QTime:
#if QT_CONFIG(datestring)
return QVariant(QTime::fromString(QString::fromLatin1(val), Qt::ISODate));
#else
return QVariant(QString::fromLatin1(val));
#endif
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
#if QT_CONFIG(datestring)
return QVariant(QDateTime::fromString(QString::fromLatin1(val),
Qt::ISODate).toLocalTime());
#else
return QVariant(QString::fromLatin1(val));
#endif
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
size_t len;
unsigned char *data = PQunescapeBytea((const unsigned char*)val, &len);
QByteArray ba(reinterpret_cast<const char *>(data), int(len));
@@ -702,7 +702,6 @@ QVariant QPSQLResult::data(int i)
return QVariant(ba);
}
default:
- case QVariant::Invalid:
qWarning("QPSQLResult::data: unknown data type");
}
return QVariant();
@@ -805,7 +804,7 @@ QSqlRecord QPSQLResult::record() const
f.setTableName(QString());
}
int ptype = PQftype(d->result, i);
- f.setMetaType(QMetaType(qDecodePSQLType(ptype)));
+ f.setMetaType(qDecodePSQLType(ptype));
f.setValue(QVariant(f.metaType())); // only set in setType() when it's invalid before
int len = PQfsize(d->result, i);
int precision = PQfmod(d->result, i);
@@ -1477,7 +1476,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
r = nullStr();
} else {
switch (field.metaType().id()) {
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
#if QT_CONFIG(datestring)
if (field.value().toDateTime().isValid()) {
// we force the value to be considered with a timezone information, and we force it to be UTC
@@ -1493,7 +1492,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
r = nullStr();
#endif // datestring
break;
- case QVariant::Time:
+ case QMetaType::QTime:
#if QT_CONFIG(datestring)
if (field.value().toTime().isValid()) {
r = QLatin1Char('\'') + field.value().toTime().toString(u"hh:mm:ss.zzz") + QLatin1Char('\'');
@@ -1503,18 +1502,18 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
r = nullStr();
}
break;
- case QVariant::String:
+ case QMetaType::QString:
r = QSqlDriver::formatValue(field, trimStrings);
if (d->hasBackslashEscape)
r.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
if (field.value().toBool())
r = QStringLiteral("TRUE");
else
r = QStringLiteral("FALSE");
break;
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
QByteArray ba(field.value().toByteArray());
size_t len;
#if defined PG_VERSION_NUM && PG_VERSION_NUM-0 >= 80200
@@ -1533,12 +1532,12 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
if (r.isEmpty())
r = QSqlDriver::formatValue(field, trimStrings);
break;
- case QVariant::Double:
+ case QMetaType::Double:
assignSpecialPsqlFloatValue(field.value().toDouble(), &r);
if (r.isEmpty())
r = QSqlDriver::formatValue(field, trimStrings);
break;
- case QVariant::Uuid:
+ case QMetaType::QUuid:
r = QLatin1Char('\'') + field.value().toString() + QLatin1Char('\'');
break;
default: