(MySQL Version 5.6.36)
We have many tables in our database that have columns typed as INT. I was just running a linq query against the resultant DataTable from our currency table... and was implicitly casting the id field as int.
A "Specified cast is not valid" exception happened.
So I decided to run a standard foreach on the datarows, getting the type of the id column... sure enough it was being returned as an INT64.
This led me further down into the rabbit hole... I opened up a console, and started up the mysql command line, with the option --column-type-info turned on... and did a simple query.
mysql> select id from currency;
Field 1: `id`
Catalog: `def`
Database: `intranet`
Table: `currency`
Org_table: `currency`
Type: LONG
Collation: binary (63)
Length: 11
Max_length: 1
Decimals: 0
Flags: NOT_NULL PRI_KEY AUTO_INCREMENT NUM PART_KEY
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
+----+
3 rows in set (0.00 sec)
This is the Describe:
+----------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| currency | varchar(3) | YES | | NULL | |
| per_usd | double | YES | | NULL | |
+----------+------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
And the Create:
CREATE TABLE `currency` ( `id` int(11) NOT NULL AUTO_INCREMENT,
`currency` varchar(3) DEFAULT NULL,
`per_usd` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
But this isn't limited to just this one table... all tables are showing INT, but returning LONG.
I've changed the id column to a MEDIUMINT in my testing, and instead of a LONG, it then returns an INT24.
Just wonder if there is something simple I am missing?