Bug #96500 MySqlDataReader.GetFieldValue<MySqlGeometry> throws InvalidCastException
| Submitted: | 10 Aug 2019 13:39 | Modified: | 11 Aug 2019 11:43 |
|---|---|---|---|
| Reporter: | Bradley Grainger (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | Connector / NET | Severity: | S3 (Non-critical) |
| Version: | 8.0.17 | OS: | Windows (10) |
| Assigned to: | CPU Architecture: | Other (x64) |
[11 Aug 2019 11:43]
MySQL Verification Team
Hello Bradley, Thank you for the report and test case. regards, Umesh
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.065 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: Calling MySqlDataReader.GetFieldValue<MySqlGeometry>() for a GEOMETRY column will throw InvalidCastException. The expected behaviour is that this method would succeed whenever MySqlDataReader.GetMySqlGeometry() is supported. How to repeat: Run the following SQL: DROP TABLE IF EXISTS geometries; CREATE TABLE geometries(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, data GEOMETRY); INSERT INTO geometries(data) VALUES (POINT(1, 1)), (POINT(1, 2)); Run the following C# code: using (var connection = new MySqlConnection("...")) { connection.Open(); using (var command = new MySqlCommand("SELECT data FROM geometries WHERE id = 1", connection)) using (var reader = command.ExecuteReader()) { reader.Read(); // works reader.GetMySqlGeometry(0); // throws InvalidCastException; expected to return same value reader.GetFieldValue<MySqlGeometry>(0); } }