summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-10-13 13:51:19 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2020-03-15 23:00:41 +0100
commitf5213ab799be73ef7e0c5fee9828d4fbcf238d95 (patch)
treeeee87a06883b6693cfe8bfe66377abc0a261f5a9 /tests/auto/sql
parent26ed956cbc5b081b972fe0c435e77e62d3f7944b (diff)
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>
Diffstat (limited to 'tests/auto/sql')
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 4533284a0f..3aa23c504d 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -238,6 +238,9 @@ private slots:
void QTBUG_53969_data() { generic_data("QMYSQL"); }
void QTBUG_53969();
+ void gisPointDatatype_data() { generic_data("QMYSQL"); }
+ void gisPointDatatype();
+
void sqlite_constraint_data() { generic_data("QSQLITE"); }
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()
{
QFETCH( QString, dbName );