Fix datatype mappings for the Mimer SQL QtSql plugin
Some of the datatype mappings for Mimer SQL are wrong and some are missing. Also, fix the datatype documentation for Mimer SQL. Fixes: QTBUG-111219 Pick-to: 6.6 Change-Id: Ic7edaaca9af9b3b480079b04b05c58ab22f34fa3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
fbb1cc234b
commit
00ed8d7822
@ -36,6 +36,7 @@ enum class MimerColumnTypes {
|
||||
Blob,
|
||||
String,
|
||||
Int,
|
||||
Numeric,
|
||||
Long,
|
||||
Float,
|
||||
Double,
|
||||
@ -221,7 +222,6 @@ static MimerColumnTypes mimerMapColumnTypes(int32_t t)
|
||||
case MIMER_TIMESTAMP:
|
||||
return MimerColumnTypes::Timestamp;
|
||||
case MIMER_INTERVAL_DAY:
|
||||
case MIMER_DECIMAL:
|
||||
case MIMER_INTERVAL_DAY_TO_HOUR:
|
||||
case MIMER_INTERVAL_DAY_TO_MINUTE:
|
||||
case MIMER_INTERVAL_DAY_TO_SECOND:
|
||||
@ -241,6 +241,10 @@ static MimerColumnTypes mimerMapColumnTypes(int32_t t)
|
||||
case MIMER_UTF8:
|
||||
case MIMER_DEFAULT_DATATYPE:
|
||||
return MimerColumnTypes::String;
|
||||
case MIMER_INTEGER:
|
||||
case MIMER_DECIMAL:
|
||||
case MIMER_FLOAT:
|
||||
return MimerColumnTypes::Numeric;
|
||||
case MIMER_BOOLEAN:
|
||||
return MimerColumnTypes::Boolean;
|
||||
case MIMER_T_BIGINT:
|
||||
@ -248,19 +252,17 @@ static MimerColumnTypes mimerMapColumnTypes(int32_t t)
|
||||
case MIMER_NATIVE_BIGINT_NULLABLE:
|
||||
case MIMER_NATIVE_BIGINT:
|
||||
return MimerColumnTypes::Long;
|
||||
case MIMER_T_FLOAT:
|
||||
case MIMER_FLOAT:
|
||||
return MimerColumnTypes::Float;
|
||||
case MIMER_NATIVE_REAL_NULLABLE:
|
||||
case MIMER_NATIVE_REAL:
|
||||
case MIMER_T_REAL:
|
||||
return MimerColumnTypes::Float;
|
||||
case MIMER_T_FLOAT:
|
||||
case MIMER_NATIVE_DOUBLE_NULLABLE:
|
||||
case MIMER_NATIVE_DOUBLE:
|
||||
case MIMER_T_DOUBLE:
|
||||
return MimerColumnTypes::Double;
|
||||
case MIMER_NATIVE_INTEGER:
|
||||
case MIMER_NATIVE_INTEGER_NULLABLE:
|
||||
case MIMER_INTEGER:
|
||||
case MIMER_NATIVE_SMALLINT_NULLABLE:
|
||||
case MIMER_NATIVE_SMALLINT:
|
||||
case MIMER_T_INTEGER:
|
||||
@ -306,6 +308,8 @@ static QMetaType::Type qDecodeMSQLType(int32_t t)
|
||||
case MIMER_NCHAR_VARYING:
|
||||
case MIMER_UTF8:
|
||||
case MIMER_DEFAULT_DATATYPE:
|
||||
case MIMER_INTEGER:
|
||||
case MIMER_FLOAT:
|
||||
return QMetaType::QString;
|
||||
case MIMER_BOOLEAN:
|
||||
return QMetaType::Bool;
|
||||
@ -314,19 +318,18 @@ static QMetaType::Type qDecodeMSQLType(int32_t t)
|
||||
case MIMER_NATIVE_BIGINT_NULLABLE:
|
||||
case MIMER_NATIVE_BIGINT:
|
||||
return QMetaType::LongLong;
|
||||
case MIMER_T_FLOAT:
|
||||
case MIMER_FLOAT:
|
||||
return QMetaType::Float;
|
||||
case MIMER_NATIVE_REAL_NULLABLE:
|
||||
case MIMER_NATIVE_REAL:
|
||||
case MIMER_T_REAL:
|
||||
return QMetaType::Float;
|
||||
case MIMER_T_FLOAT:
|
||||
case MIMER_NATIVE_DOUBLE_NULLABLE:
|
||||
case MIMER_NATIVE_DOUBLE:
|
||||
case MIMER_T_DOUBLE:
|
||||
return QMetaType::Double;
|
||||
case MIMER_NATIVE_INTEGER_NULLABLE:
|
||||
case MIMER_T_INTEGER:
|
||||
case MIMER_INTEGER:
|
||||
case MIMER_NATIVE_INTEGER:
|
||||
return QMetaType::Int;
|
||||
case MIMER_NATIVE_SMALLINT_NULLABLE:
|
||||
case MIMER_T_SMALLINT:
|
||||
@ -407,7 +410,7 @@ static int32_t qLookupMimDataType(QStringView s)
|
||||
if (s == u"DOUBLE PRECISION")
|
||||
return MIMER_T_DOUBLE;
|
||||
if (s == u"INTEGER")
|
||||
return MIMER_INTEGER;
|
||||
return MIMER_T_INTEGER;
|
||||
if (s == u"SMALLINT")
|
||||
return MIMER_T_SMALLINT;
|
||||
if (s == u"DATE")
|
||||
@ -724,7 +727,7 @@ QVariant QMimerSQLResult::data(int i)
|
||||
case QSql::LowPrecisionInt64:
|
||||
return static_cast<qint64>(resDouble);
|
||||
case QSql::LowPrecisionDouble:
|
||||
return resDouble;
|
||||
return static_cast<qreal>(resDouble);
|
||||
case QSql::HighPrecision:
|
||||
return QString::number(resDouble, 'g', 17);
|
||||
}
|
||||
@ -776,6 +779,7 @@ QVariant QMimerSQLResult::data(int i)
|
||||
}
|
||||
return byteArray;
|
||||
}
|
||||
case MimerColumnTypes::Numeric:
|
||||
case MimerColumnTypes::String: {
|
||||
wchar_t resString_w[maxStackStringSize + 1];
|
||||
// Get size
|
||||
@ -797,8 +801,9 @@ QVariant QMimerSQLResult::data(int i)
|
||||
return QString::fromWCharArray(largeResString_w.data());
|
||||
}
|
||||
}
|
||||
setLastError(qMakeError(msgCouldNotGet("string", i),
|
||||
err, QSqlError::StatementError, d->drv_d_func()));
|
||||
setLastError(qMakeError(msgCouldNotGet(
|
||||
mimDataType == MimerColumnTypes::Numeric ? "numeric" : "string", i),
|
||||
err, QSqlError::StatementError, d->drv_d_func()));
|
||||
return QVariant(QMetaType(type), nullptr);
|
||||
}
|
||||
case MimerColumnTypes::Clob: {
|
||||
@ -1090,14 +1095,16 @@ bool QMimerSQLResult::exec()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MimerColumnTypes::Numeric:
|
||||
case MimerColumnTypes::String: {
|
||||
QByteArray string_b = val.toString().trimmed().toUtf8();
|
||||
const char *string_u = string_b.constData();
|
||||
err = MimerSetString8(d->statementhandle, i + 1, string_u);
|
||||
if (!MIMER_SUCCEEDED(err)) {
|
||||
setLastError(
|
||||
qMakeError(msgCouldNotSet("string", i),
|
||||
err, QSqlError::StatementError, d->drv_d_func()));
|
||||
qMakeError(msgCouldNotSet(
|
||||
mimDataType == MimerColumnTypes::Numeric ? "numeric" : "string", i),
|
||||
err, QSqlError::StatementError, d->drv_d_func()));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -494,63 +494,81 @@
|
||||
\li INTEGER
|
||||
\li 32-bit signed integer
|
||||
\li typedef qint32
|
||||
\row
|
||||
\li INTEGER(n)
|
||||
\li Integer with up to 45 digits precision
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li BIGINT
|
||||
\li 64-bit signed integer
|
||||
\li typedef qint64
|
||||
\row
|
||||
\li REAL
|
||||
\li 32-bit Single-precision floating point
|
||||
\li typedef qreal
|
||||
\li 32-bit Single-precision IEEE floating point
|
||||
\li typedef float
|
||||
\row
|
||||
\li DOUBLE PRECISION
|
||||
\li 64-bit Double-precision floating point
|
||||
\li 64-bit Double-precision IEEE floating point
|
||||
\li Mapped to QString for high precision doubles, otherwise qreal
|
||||
\row
|
||||
\li FLOAT
|
||||
\li 64-bit Double-precision floating point
|
||||
\li typedef qreal
|
||||
\li 64-bit Double-precision IEEE floating point
|
||||
\li Mapped to QString for high precision doubles, otherwise qreal
|
||||
\row
|
||||
\li FLOAT(n)
|
||||
\li Floating point with up to 45 digits precision
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li DECIMAL(p,s)
|
||||
\li Decimal with up to 45 digits precision and scale
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li CHAR
|
||||
\li Fixed-length, null-terminated character string
|
||||
\li Fixed-length character Latin-1 string (CHAR or character)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li VARCHAR
|
||||
\li Null-terminated varying length string
|
||||
\li Variable length Latin-1 string (VARCHAR or CHARACTER VARYING)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li NCHAR
|
||||
\li Fixed-length, null-terminated Unicode character string
|
||||
\li Fixed-length Unicode string (NCHAR or NATIONAL CHARACTER)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li NVARCHAR
|
||||
\li Null-terminated varying length Unicode string
|
||||
\li Variable length Unicode string (NVARCHAR or NATIONAL CHARACTER VARYING)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li BINARY
|
||||
\li Fixed length binary data
|
||||
\li Mapped to QByteArray
|
||||
\row
|
||||
\li VARBINARY
|
||||
\li Variable length binary data (VARBINARY or BINARY VARYING)
|
||||
\li Mapped to QByteArray
|
||||
\row
|
||||
\li BLOB
|
||||
\li Not null-terminated varying binary string with 4-byte string
|
||||
length indicator
|
||||
\li Binary large object (BLOB or BINARY LARGE OBJECT)
|
||||
\li Mapped to QByteArray
|
||||
\row
|
||||
\li CLOB
|
||||
\li Character large string object
|
||||
\li Latin-1 character large object (CLOB or CHARACTER LARGE OBJECT)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li NCLOB
|
||||
\li National Character large string object
|
||||
\li Unicode character large object (NCLOB or NATIONAL CHARACTER LARGE OBJECT)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li DATE
|
||||
\li Null-terminated character string of the following format:
|
||||
yyyy-mm-dd
|
||||
\li Date consisting of year, month, and day
|
||||
\li Mapped to QDate
|
||||
\row
|
||||
\li TIME
|
||||
\li Null-terminated character string of the following format: hh.mm.ss
|
||||
\li Time consisting of hours, minute, seconds with optional fractional seconds
|
||||
\li Mapped to QTime
|
||||
\row
|
||||
\li TIMESTAMP
|
||||
\li Null-terminated character string of the following format: yyyy-mm-dd-hh.mm.ss.nnnnnn
|
||||
\li Date and time with optional fractional seconds
|
||||
\li Mapped to QDateTime
|
||||
\row
|
||||
\li BUILTIN.UUID
|
||||
@ -561,7 +579,56 @@
|
||||
\li Boolean
|
||||
\li bool
|
||||
\row
|
||||
\li DECIMAL(p,s)
|
||||
\li By default mapping to QString
|
||||
\li INTERVAL YEAR(7)
|
||||
\li Year, format '±yyyyyyy' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL YEAR(7) TO MONTH
|
||||
\li Year to month, format '±yyyyyyy-mm' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL MONTH(7)
|
||||
\li Month, format '±mmmmmmm' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL DAY(7)
|
||||
\li Day, format '±ddddddd' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL DAY(7) TO HOUR
|
||||
\li Day to hour, format '±ddddddd hh' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL DAY(7) TO MINUTE
|
||||
\li Day to minute, format '±ddddddd hh:mm' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL DAY(7) TO SECOND(9)
|
||||
\li Day to second, format '±ddddddd hh:mm:ss[.fffffffff]' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL HOUR(8)
|
||||
\li Hour, format '±hhhhhhhh' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL HOUR(8) TO MINUTE
|
||||
\li Hour to minute, format '±hhhhhhhh:mm' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL HOUR(8) TO SECOND(9)
|
||||
\li Hour to second, format '±hhhhhhhh:mm:ss[.fffffffff]' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL MINUTE(10)
|
||||
\li Minute, format '±mmmmmmmmmm' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL MINUTE(10) TO SECOND(9)
|
||||
\li Minute to second, format '±mmmmmmmmmm:ss[.fffffffff]' (max precision)
|
||||
\li Mapped to QString
|
||||
\row
|
||||
\li INTERVAL SECOND(12,9)
|
||||
\li Second, format '±ssssssssssss[.fffffffff]' (max precision)
|
||||
\li Mapped to QString
|
||||
\endtable
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user