QMySQL: return QVariant::ByteArray for POINT column
qDecodeMYSQLType() did not handle FIELD_TYPE_GEOMETRY and therefore the type for a POINT column was incorrectly treated as QVariant::String. Even the type can not (yet) be properly decoded to a QPoint, treating it as QVariant::ByteArray is the better option here. Fixes: QTBUG-72140 Change-Id: I12e75b326ae3acb75cb36f2e650464528bd43c0e Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
parent
26ed956cbc
commit
f5213ab799
@ -294,6 +294,7 @@ static QMetaType::Type qDecodeMYSQLType(int mysqltype, uint flags)
|
|||||||
case FIELD_TYPE_TINY_BLOB :
|
case FIELD_TYPE_TINY_BLOB :
|
||||||
case FIELD_TYPE_MEDIUM_BLOB :
|
case FIELD_TYPE_MEDIUM_BLOB :
|
||||||
case FIELD_TYPE_LONG_BLOB :
|
case FIELD_TYPE_LONG_BLOB :
|
||||||
|
case FIELD_TYPE_GEOMETRY :
|
||||||
type = (flags & BINARY_FLAG) ? QMetaType::QByteArray : QMetaType::QString;
|
type = (flags & BINARY_FLAG) ? QMetaType::QByteArray : QMetaType::QString;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -238,6 +238,9 @@ private slots:
|
|||||||
void QTBUG_53969_data() { generic_data("QMYSQL"); }
|
void QTBUG_53969_data() { generic_data("QMYSQL"); }
|
||||||
void QTBUG_53969();
|
void QTBUG_53969();
|
||||||
|
|
||||||
|
void gisPointDatatype_data() { generic_data("QMYSQL"); }
|
||||||
|
void gisPointDatatype();
|
||||||
|
|
||||||
void sqlite_constraint_data() { generic_data("QSQLITE"); }
|
void sqlite_constraint_data() { generic_data("QSQLITE"); }
|
||||||
void sqlite_constraint();
|
void sqlite_constraint();
|
||||||
|
|
||||||
@ -4080,6 +4083,25 @@ void tst_QSqlQuery::QTBUG_53969()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QSqlQuery::gisPointDatatype()
|
||||||
|
{
|
||||||
|
QFETCH(QString, dbName);
|
||||||
|
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||||
|
CHECK_DATABASE(db);
|
||||||
|
|
||||||
|
QSqlQuery sqlQuery(db);
|
||||||
|
const auto tableName = qTableName("qtbug72140", __FILE__, db);
|
||||||
|
tst_Databases::safeDropTable(db, tableName);
|
||||||
|
QString sqlCommand = QStringLiteral("CREATE TABLE %1 (`lonlat_point` POINT NULL) ENGINE = InnoDB;").arg(tableName);
|
||||||
|
QVERIFY(sqlQuery.exec(sqlCommand));
|
||||||
|
sqlCommand = QStringLiteral("INSERT INTO %1(lonlat_point) VALUES(ST_GeomFromText('POINT(1 1)'));").arg(tableName);
|
||||||
|
QVERIFY(sqlQuery.exec(sqlCommand));
|
||||||
|
sqlCommand = QStringLiteral("SELECT * FROM %1;").arg(tableName);
|
||||||
|
QVERIFY(sqlQuery.exec(sqlCommand));
|
||||||
|
QCOMPARE(sqlQuery.record().field(0).type(), QVariant::Type::ByteArray);
|
||||||
|
QVERIFY(sqlQuery.next());
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QSqlQuery::oraOCINumber()
|
void tst_QSqlQuery::oraOCINumber()
|
||||||
{
|
{
|
||||||
QFETCH( QString, dbName );
|
QFETCH( QString, dbName );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user