| Bug #72828 | Connection.GetSchema doesn't identify primary keys by name | ||
|---|---|---|---|
| Submitted: | 1 Jun 2014 22:49 | Modified: | 19 Sep 2022 15:34 |
| Reporter: | Colin Paterson | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / NET | Severity: | S3 (Non-critical) |
| Version: | 6.8.3, 6.9.3 | OS: | Windows (7 x64) |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | Connection, GetSchema, meta-data | ||
[17 Nov 2014 10:33]
Chiranjeevi Battula
Hello Colin Paterson, Thank you for the bug report and test case. Verified this behavior on Visual Studio 2013 (C#.Net) with MySQL Connector/Net 6.9.3. Thanks, Chiranjeevi
[19 Sep 2022 15:27]
Omar Chavez
Posted by developer: This is not a bug from the Connector, these values came directly from the server, verified using Workbench
[19 Sep 2022 15:34]
Colin Paterson
Thanks for the quick turnaround :-D Talk again in another decade. I think I hacked my way through this 7 years ago. LOL!!!

Description: When calling the GetSchema method of the connection object passing in the "Indexes" or the "IndexColumns" collection name, you are returned a DataTable with indexes including the PrimaryKeys. This is the only way to get primary key information as there is no PrimaryKeys collection. In either case the column INDEX_NAME contains the name of the index/constraint for the other index/constraint types. For Primary Keys however the value in the INDEX_NAME field always contains the string "PRIMARY" and not the name of the constraint as you would expect. How to repeat: Call the following on any connection to a database that has a table with a Primary Key _connection.GetSchema("IndexColumns"); _connection.GetSchema("Indexes"); Where _connection is a MySqlConnection object. Suggested fix: The INDEX_NAME column should contain the name given to the Primary Key constrain on creation.